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 import com.sun.syndication.io.SyndFeedOutput;
23
24 /***
25 * It Converts any RSS/Atom feed type to a an RSS/Atom feed of the
26 * specified type.
27 * <p>
28 * @author Alejandro Abdelnur
29 *
30 */
31 public class FeedConverter {
32
33 public static void main(String[] args) {
34 boolean ok = false;
35 if (args.length==2) {
36 try {
37 String outputType = args[0];
38
39 URL feedUrl = new URL(args[1]);
40
41 SyndFeedInput input = new SyndFeedInput();
42 SyndFeedI feed = input.build(feedUrl.openStream());
43 feed.setFeedType(outputType);
44 SyndFeedOutput output = new SyndFeedOutput();
45 output.output(feed,System.out);
46
47 ok = true;
48 }
49 catch (Exception ex) {
50 System.out.println("ERROR: "+ex.getMessage());
51 }
52 }
53
54 if (!ok) {
55 System.out.println();
56 System.out.println("FeedConverter converts between syndication feeds types.");
57 System.out.println("The first parameter must be the feed type to convert to.");
58 System.out.println(" [valid values are: rss_0.9, rss_0.91, rss_0.92, rss_0.93, ]");
59 System.out.println(" [ rss_0.94, rss_1.0, rss_2.0 & atom_0.3 ]");
60 System.out.println("The second parameter must be the URL of the feed to convert.");
61 System.out.println();
62 }
63 }
64
65 }