Sams Teach Yourself Java™ in 24 Hours (Covering Java 7 and Android)

(singke) #1
ptg7068951

Summary 309

55: Aggregator aggie = new Aggregator(arguments[0]);
56: aggie.listItems();
57: } else{
58: System.out.println(“Usage: java Aggregator rssUrl”);
59: }
60: }
61: }


Before running the application, set up acommand-line argument for the
feed you’d like to read, which can be any RSS feed. If you don’t know any,
use http://feeds.drudge.com/retort, which contains headlines from the
Drudge Retort, an online news site that I publish.


Sample output from the feedis shown in Figure 21.1.


LISTING 21.4 Continued


FIGURE 21.1
Running theAggregator
application.

BY THE WAY
Yo u c a n f i n d o u t m o r e a b o u t
the RSS XML dialect from the
RSS Advisory Board website at
http://www.rssboard.org. I’m the chair-
man of the board,which offers
guidance on the format and a
directory of software that can
be used to read RSS feeds.

Summary


The Java language liberates software from dependence on a particular oper-
ating system. The program you write with the language on a Windows box
creates class files that can be run on a Linux server or a Mac OS X computer.


XMLachieves a similar liberation for the data produced by software. If XML
data follows the simple rules required to make it well formed, you can read
it with any software that parses XML. You don’t need to keep the originating
program around just to ensure there’s always a way to access it.


The XOM library makes it easy to read and write XMLdata.


When you’re using Java and XML, you can declare your independence
from two of the major obstacles faced by computer programmers for
decades: obsolete data and obsolete operating systems.

Free download pdf