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