How to Build RSS Feed Client in Java

  • Post last modified:December 15, 2022
  • Reading time:5 mins read


  • RSS feeds are one of the common way to fetch the latest news articles from popular websites.
  • In this blog we will use java library rome library to fetch articles from tech blog website using rss feed.

Use Case

  • Our use case is to fetch rss feeds from popular blog page such google cloud blog, uber engineering blog etc.
  • If you explore , you will find rss feed for most of the blog website.
  • If you can’t find such logo on the website then we can right click on the page and view source and search rss link.

Building Client

  • Now that we have rss feed url , we can use it our advantage to read it by pulling the articles.
  • We will first create project RSSReaderClient in IDE. Then first task is to add rome library to pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""





POJO to Store NewsArticles

  • Lets create NewsArticle POJO to store the article data. We will need it later.
import java.util.List;

public class NewsArticle {
    private String title;
    private String link;
    private String imgUrl;
    private List<String> categories;

    public String getPublishedDate() {
        return publishedDate;

    public void setPublishedDate(String publishedDate) {
        this.publishedDate = publishedDate;

    private String publishedDate;

    public String getTitle() {
        return title;

    public void setTitle(String title) {
        this.title = title;

    public String getLink() {
        return link;

    public void setLink(String link) { = link;

    public String getImgUrl() {
        return imgUrl;

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;

    public List<String> getCategories() {
        return categories;

    public void setCategories(List<String> categories) {
        this.categories = categories;

    public String toString() {
        return "NewsArticle{" +
                "title='" + title + '\'' +
                ", link='" + link + '\'' +
                ", imgUrl='" + imgUrl + '\'' +
                ", categories=" + categories +
                ", publishedDate='" + publishedDate + '\'' +

Utility Class for RSS Reader

  • Also , we will create utility class that will perform the read rss feed operation and then map the result to our NewsArticle POJO that we created earlier.
import com.rometools.rome.feed.synd.SyndEntry;
import com.rometools.rome.feed.synd.SyndFeed;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class RSSReaderUtil {

    public static List<NewsArticle> read(String feedUrl) throws IOException, FeedException {
        URL feedSource = new URL(feedUrl);
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = XmlReader(feedSource));
        Iterator itr = feed.getEntries().iterator();
        List<NewsArticle> results = new ArrayList<>();
        while (itr.hasNext()) {
            SyndEntry syndEntry = (SyndEntry);

        return results;

     * Map to Article
     * @param syndEntry
    private static NewsArticle mapToArticle(SyndEntry syndEntry) {
        NewsArticle newsArticle = new NewsArticle();
        return newsArticle;

Reader Client

  • Once we have Utility ready, then all we have to do is to use it in our client.
  • We have list of feeds that we will target and pull the articles from
  • We will pass it our method , that will return the response as List<NewsArticle>
  • Once we have our response , all we have to do is to print it.

import java.util.List;

public class RSSReader {

    public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException, FeedException {
        URL feedSource = new URL("");
        List<String> targetFeedsList = List.of("",

        for(String url : targetFeedsList){
            List<NewsArticle> results =;
            System.out.println("url : "+url);
  > System.out.println(a.toString()));

Testing Client

  • Let’s run our java applications , as per our logic , our reader will read the list of feeds and print it . 
  • As you can see in the screenshot of the output, we have all the latest rss feeds from google cloud blog.


  • In this article we have used Java library rome to fetch RSS feeds from open source blogs . We can schedule pull articles from source using any java based schedulers or even cron on unix which runs jar and write the content some destination like firebase or relation database.
  • We can use this logic to serve users by either building mobile apps or web apps or browser extensions such as chrome.

Bonus Tip

Leave a Reply