1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.sun.syndication.samples;
18
19 import com.sun.syndication.feed.synd.SyndFeed;
20 import com.sun.syndication.io.SyndFeedInput;
21 import com.sun.syndication.io.XmlReader;
22
23 import java.net.URL;
24
25 /***
26 * It Reads and prints any RSS/Atom feed type.
27 * <p>
28 * @author Alejandro Abdelnur
29 *
30 */
31 public class FeedReader {
32
33 public static void main(String[] args) {
34 boolean ok = false;
35 if (args.length==1) {
36 try {
37 URL feedUrl = new URL(args[0]);
38 SyndFeedInput input = new SyndFeedInput();
39
40 SyndFeed feed = input.build(new XmlReader(feedUrl));
41
42 System.out.println(feed);
43
44 ok = true;
45 }
46 catch (Exception ex) {
47 ex.printStackTrace();
48 System.out.println("ERROR: "+ex.getMessage());
49 }
50 }
51
52 if (!ok) {
53 System.out.println();
54 System.out.println("FeedReader reads and prints any RSS/Atom feed type.");
55 System.out.println("The first parameter must be the URL of the feed to read.");
56 System.out.println();
57 }
58 }
59
60 }