Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

RSS (Rich Site Summary or Really Simple Syndication) is a web feed standard that provides readers with an aggregated content from various locations. The user can see what’s been published recently on his favorite blogs, news sites, etc – all in a single place.

Applications can also use RSS to read, manipulate, or publish information through RSS feeds.

This article gives an overview of how to process RSS feeds in Java with the Rome API.

2. Maven Dependencies

We need to add the dependency for Rome API to our project:

<dependency>			
    <groupId>rome</groupId>			
    <artifactId>rome</artifactId>			
    <version>1.0</version>
</dependency>

We can find the latest version on Maven Central.

3. Creating a New RSS Feed

First, let’s create a new RSS feed with the Rome API using the default implementation SyndFeedImpl of the SyndFeed interface. This interface is able to handle all RSS flavors, so we can always feel safe to use it:

SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("rss_1.0");
feed.setTitle("Test title");
feed.setLink("http://www.somelink.com");
feed.setDescription("Basic description");

In this snippet, we’ve created an RSS feed with standard RSS fields such as a title, link, and description. SyndFeed gives the opportunity of adding many more fields, including authors, contributors, copyrights, modules, published dates, images, foreign markups, and languages.

4. Adding an Entry

As we’ve created the RSS feed, now we can add an entry to it. In the example below, we use the default implementation SyndEntryImpl of the SyndEntry interface to create a new entry:

SyndEntry entry = new SyndEntryImpl();
entry.setTitle("Entry title");        
entry.setLink("http://www.somelink.com/entry1");
    
feed.setEntries(Arrays.asList(entry));

5. Adding a Description

As our entry is pretty empty so far, let’s add a description for it. We can do this by using the default implementation SyndContentImpl of the SyndContent interface:

SyndContent description = new SyndContentImpl();
description.setType("text/html");
description.setValue("First entry");

entry.setDescription(description);

With the setType method, we have specified that the content of our description will be a text or HTML.

6. Adding a Category

RSS entries are often classified into categories to simplify the task of finding entries that we are interested in. Let’s see how we can add a category to the entry using the default implementation SyndCategoryImpl of the SyndCategory interface:

List<SyndCategory> categories = new ArrayList<>();
SyndCategory category = new SyndCategoryImpl();
category.setName("Sophisticated category");
categories.add(category);

entry.setCategories(categories);

7. Publishing the Feed

We already have an RSS feed with an entry. Now we want to publish it. For the purpose of this article, by publishing, we mean writing the feed to a stream:

Writer writer = new FileWriter("xyz.txt");
SyndFeedOutput syndFeedOutput = new SyndFeedOutput();
syndFeedOutput.output(feed, writer);
writer.close();

8. Reading an External Feed

We already know how to create a new feed, but sometimes we just need to connect to an existing one.

Let’s see how to read/load a feed, given its URL:

URL feedSource = new URL("http://rssblog.whatisrss.com/feed/");
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedSource));

9. Conclusion

In this article, we have shown how to create an RSS feed with some entries, how to publish the feed, and how to read external feeds.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 4th December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW