我们使用下面的代码来阅读一个RSS | ATOM feed,有没有办法找到RSS | 博客提要的 ATOM URL 给出博客站点(例如for http://my.typepad.com or http://occupylosangeles.org/
)。这应该类似于 google.com/reader 所做的。
import com.sun.syndication.feed.atom.Feed;
import com.sun.syndication.feed.module.Module;
import com.sun.syndication.feed.synd.SyndCategory;
import com.sun.syndication.feed.synd.SyndContent;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndFeedImpl;
import com.sun.syndication.fetcher.FeedFetcher;
import com.sun.syndication.fetcher.FetcherEvent;
import com.sun.syndication.fetcher.FetcherListener;
import com.sun.syndication.fetcher.impl.FeedFetcherCache;
import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);
// register listener to feed
FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
fetcher.addFetcherEventListener(listener);
// Mechanism to read feeds via Rome Fetcher
SyndFeed feed = fetcher.retrieveFeed(new URL(feedURL));