使用罗马阅读RSS
import com.sun.syndication.feed.synd.SyndCategoryImpl; import com.sun.syndication.feed.synd.SyndContentImpl;/*来 自 N o w J a v a . c o m*/ import com.sun.syndication.feed.synd.SyndEntry; import com.sun.syndication.feed.synd.SyndFeed; import com.sun.syndication.feed.synd.SyndLinkImpl; import com.sun.syndication.io.SyndFeedInput; import com.sun.syndication.io.XmlReader; import java.net.URL; import java.util.List; public class RomeEx2 { /* 来自 *时代Java*/ public static void main(String[] args) { try { String urlString = "http://feeds.reuters.com/reuters/topNews"; URL feedUrl = new URL(urlString); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedUrl)); System.out.println("Feed Title: " + feed.getTitle()); //Get the entry items... for (SyndEntry entry : (List<SyndEntry>) feed.getEntries()) { System.out.println("Title: " + entry.getTitle()); System.out.println("Unique Identifier: " + entry.getUri()); System.out.println("Updated Date: " + entry.getUpdatedDate()); // Get the Links for (SyndLinkImpl link : (List<SyndLinkImpl>) entry .getLinks()) { System.out.println("Link: " + link.getHref()); } // Get the Contents for (SyndContentImpl content : (List<SyndContentImpl>) entry .getContents()) { System.out.println("Content: " + content.getValue()); } // Get the Categories