錛屼絾鏄繕鏄湁涓閮ㄥ垎涔辯爜銆備粖澶╂壘浜嗕竴澶╀篃娌℃湁瑙e喅銆傘傘?br />
聽1聽/*
聽2聽聽*聽Created聽on聽2006-7-11
聽3聽聽*
聽4聽聽*聽TODO聽To聽change聽the聽template聽for聽this聽generated聽file聽go聽to
聽5聽聽*聽Window聽-聽Preferences聽-聽Java聽-聽Code聽Style聽-聽Code聽Templates
聽6聽聽*/
聽7聽package聽border;
聽8聽
聽9聽import聽java.io.FileWriter;
10聽import聽java.io.Writer;
11聽import聽java.net.URL;
12聽import聽java.util.List;
13聽
14聽import聽com.sun.syndication.feed.synd.SyndContent;
15聽import聽com.sun.syndication.feed.synd.SyndEntry;
16聽import聽com.sun.syndication.feed.synd.SyndFeed;
17聽import聽com.sun.syndication.fetcher.FeedFetcher;
18聽import聽com.sun.syndication.fetcher.impl.FeedFetcherCache;
19聽import聽com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
20聽import聽com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
21聽import聽com.sun.syndication.io.SyndFeedOutput;
22聽
23聽/**
24聽聽*聽@author聽Border
25聽聽*聽
26聽聽*聽TODO聽To聽change聽the聽template聽for聽this聽generated聽type聽comment聽go聽to聽Window聽-
27聽聽*聽Preferences聽-聽Java聽-聽Code聽Style聽-聽Code聽Templates
28聽聽*/
29聽public聽class聽RSSReader聽{
30聽聽聽聽聽private聽static聽final聽String聽feedType聽=聽"rss_2.0";
31聽
32聽聽聽聽聽public聽static聽void聽main(String[]聽args)聽throws聽Exception聽{
33聽
34聽聽聽聽聽聽聽聽聽String聽filename聽=聽"E:\\ROME\\feed_fetcher2.xml";
35聽聽聽聽聽聽聽聽聽try聽{
36聽聽聽聽聽聽聽聽聽聽聽聽聽FeedFetcherCache聽feedInfoCache聽=聽HashMapFeedInfoCache.getInstance();
37聽聽聽聽聽聽聽聽聽聽聽聽聽FeedFetcher聽feedFetcher聽=聽new聽HttpURLFeedFetcher();
38聽聽聽聽聽聽聽聽聽聽聽聽聽SyndFeed聽feed聽=聽feedFetcher.retrieveFeed(new聽URL(
39聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽"http://www.aygfsteel.com/border/Rss.aspx"));
40聽
41聽聽聽聽聽聽聽聽聽聽聽聽聽feed.setFeedType(feedType);
42聽聽聽聽聽聽聽聽聽聽聽聽聽feed.setTitle("Border's聽Blog");
43聽聽聽聽聽聽聽聽聽聽聽聽聽feed.setDescription("聽java聽Web3D聽FreeBsd聽");
44聽聽聽聽聽聽聽聽聽聽聽聽聽feed.setAuthor("聽By:border聽");
45聽聽聽聽聽聽聽聽聽聽聽聽聽feed.setLink("聽http://www.aygfsteel.com/border聽");
46聽
47聽聽聽聽聽聽聽聽聽聽聽聽聽List聽entryList聽=聽feed.getEntries();
48聽
49聽聽聽聽聽聽聽聽聽聽聽聽聽for聽(int聽i聽=聽0;聽i聽<聽entryList.size();聽i++)聽{
50聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SyndEntry聽entry聽=聽(SyndEntry)聽entryList.get(i);
51聽
52聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽entry.setPublishedDate(entry.getPublishedDate());
53聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽entry.setTitle(new聽String(entry.getTitle().getBytes("utf-8")));
54聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽entry.setLink(entry.getLink());
55聽
56聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SyndContent聽content聽=聽entry.getDescription();
57聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽content.setValue(new聽String(content.getValue()
58聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽.getBytes("utf-8")));
59聽聽聽聽聽聽聽聽聽聽聽聽聽}
60聽聽聽聽聽聽聽聽聽聽聽聽聽SyndFeedOutput聽output聽=聽new聽SyndFeedOutput();
61聽聽聽聽聽聽聽聽聽聽聽聽聽Writer聽writer聽=聽new聽FileWriter(filename);
62聽聽聽聽聽聽聽聽聽聽聽聽聽output.output(feed,聽writer);
63聽
64聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println("The聽feed聽has聽been聽written聽to聽the聽file聽["
65聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽+聽filename聽+聽"]");
66聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println("聽ok聽!");
67聽
68聽聽聽聽聽聽聽聽聽}聽catch聽(Exception聽e)聽{
69聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println("ERROR:聽"聽+聽e.getMessage());
70聽聽聽聽聽聽聽聽聽}
71聽聽聽聽聽}
72聽}
涓嬮潰鏄敓鎴愮殑xml鏂囦歡錛?br />
聽1聽<?xml聽version="1.0"聽encoding="UTF-8"?>
聽2聽<rss聽xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"聽xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"聽xmlns:dc="http://purl.org/dc/elements/1.1/"聽version="2.0">
聽3聽聽聽<channel>
聽4聽聽聽聽聽<title>Border's聽Blog</title>
聽5聽聽聽聽聽<link>http://www.aygfsteel.com/border</link>
聽6聽聽聽聽聽<description>java聽Web3D聽FreeBsd</description>
聽7聽聽聽聽聽<language>zh-cn</language>
聽8聽聽聽聽聽<pubDate>Thu,聽06聽Jul聽2006聽11:05:25聽GMT</pubDate>
聽9聽聽聽聽聽<dc:creator>By:border</dc:creator>
10聽聽聽聽聽<dc:date>2006-07-06T11:05:25Z</dc:date>
11聽聽聽聽聽<dc:language>zh-cn</dc:language>
12聽聽聽聽聽<item>
13聽聽聽聽聽聽聽<title>鍏嶈垂MySQL鏁版嵁搴撶敵璀?/span></title>
14聽聽聽聽聽聽聽<link>http://www.aygfsteel.com/border/archive/2006/07/06/57015.html</link>
15聽聽聽聽聽聽聽<description>聽<a聽><img聽alt=""聽src="http://www.kuangfeng.cn/blog/wp-content/uploads/2006/03/db4free.jpg"聽align="left"聽border="0"聽/></a><br聽/><br聽/><br聽/><br聽/><a聽>Db4free</a>錛氫笓涓氭彁渚涘厤璐規暟鎹簱鏈嶅姟錛屾敮鎸伮燤ySQL聽5.0錆?.1錛屾敮鎸佷嬌鐢≒hpmyadmin榪涜綆$悊錛屼互鍚庤繕灝嗘墿灞曟敮鎸丳ostgreSQL,聽Firebird聽絳夋暟鎹簱.<img聽src聽="http://www.aygfsteel.com/border/aggbug/57015.html"聽width聽=聽"1"聽height聽=聽"1"聽/><br><br><div聽align=right><a聽style="text-decoration:none;"聽href="/border/"聽target="_blank">Border</a>聽2006-07-06聽19:05聽<a聽href="/border/archive/2006/07/06/57015.html#Feedback"聽target="_blank"聽style="text-decoration:none;">鍙戣〃璇勮</a></div></description>
16聽聽聽聽聽聽聽<pubDate>Thu,聽06聽Jul聽2006聽11:05:00聽GMT</pubDate>
17聽聽聽聽聽聽聽<guid聽isPermaLink="false">http://www.aygfsteel.com/border/archive/2006/07/06/57015.html</guid>
18聽聽聽聽聽聽聽<dc:creator>Border</dc:creator>
19聽聽聽聽聽聽聽<dc:date>2006-07-06T11:05:00Z</dc:date>
20聽聽聽聽聽</item>
21聽聽聽聽聽<item>
22聽聽聽聽聽聽聽<title>鍒氬垰澶у帵鏅冪殑鍒╁錛屾槸涓嶆槸鏈変簺鍦伴渿鍙柯?-聽聽鍖椾含</title>
23聽聽聽聽聽聽聽<link>http://www.aygfsteel.com/border/archive/2006/07/04/56502.html</link>
24聽聽聽聽聽聽聽<description>聽聽聽聽聽聽鍒氬垰澶у帵鏅冪殑鍒╁錛屾槸涓嶆槸鏈変簺鍦伴渿鍙柯狅紝鍦?7灞傛劅瑙夋瘮杈冨帀瀹籌紝涓嶇煡閬撳湪鍖椾含鐨勫叾浠栧悓蹇楁湁娌℃湁娉ㄦ剰鍒搬嬌<img聽src聽="http://www.aygfsteel.com/border/aggbug/56502.html"聽width聽=聽"1"聽height聽=聽"1"聽/><br><br><div聽align=right><a聽style="text-decoration:none;"聽href="/border/"聽target="_blank">Border</a>聽2006-07-04聽12:20聽<a聽href="/border/archive/2006/07/04/56502.html#Feedback"聽target="_blank"聽style="text-decoration:none;">鍙戣〃璇勮</a></div></description>
25聽聽聽聽聽聽聽<pubDate>Tue,聽04聽Jul聽2006聽04:20:00聽GMT</pubDate>
26聽聽聽聽聽聽聽<guid聽isPermaLink="false">http://www.aygfsteel.com/border/archive/2006/07/04/56502.html</guid>
27聽聽聽聽聽聽聽<dc:creator>Border</dc:creator>
28聽聽聽聽聽聽聽<dc:date>2006-07-04T04:20:00Z</dc:date>
29聽聽聽聽聽</item>
30聽聽聽聽聽<item>
31聽聽聽聽聽聽聽<title>閫氳繃js絳夋瘮鎵╁ぇ鍥劇墖鐨勬瘮浼?/span></title>
32聽聽聽聽聽聽聽<link>http://www.aygfsteel.com/border/archive/2006/07/03/56279.html</link>
33聽聽聽聽聽聽聽<description>鎽樿:聽聽聽聽鍦ㄥ仛web搴垮彂鐨勬椂憧欙紝鏄劇ず鍥劇墖鏄粡甯哥敤鍒搬總鍦ㄩ粯璁ょ殑鎯呭喌涓嬪浘鐗囨槸鎵╁厖錛屼絾鏄湁鐨勬椂憧欐樉紺烘晥鏋滀細涓嶅浜烘剰銆傛湁鏃跺鍣ㄧ殑澶у皬鏄浐瀹氱殑錛屾垜浠鎶婂浘鐗囩瓑姣旀墿澶п嬌<a聽href='http://www.aygfsteel.com/border/archive/2006/07/03/56279.html'>闃呰鍏ㄦ枃</a>餼?/span><img聽src聽="http://www.aygfsteel.com/border/aggbug/56279.html"聽width聽=聽"1"聽height聽=聽"1"聽/><br><br><div聽align=right><a聽style="text-decoration:none;"聽href="/border/"聽target="_blank">Border</a>聽2006-07-03聽12:13聽<a聽href="/border/archive/2006/07/03/56279.html#Feedback"聽target="_blank"聽style="text-decoration:none;">鍙戣〃璇勮</a></div></description>
34聽聽聽聽聽聽聽<pubDate>Mon,聽03聽Jul聽2006聽04:13:00聽GMT</pubDate>
35聽聽聽聽聽聽聽<guid聽isPermaLink="false">http://www.aygfsteel.com/border/archive/2006/07/03/56279.html</guid>
36聽聽聽聽聽聽聽<dc:creator>Border</dc:creator>
37聽聽聽聽聽聽聽<dc:date>2006-07-03T04:13:00Z</dc:date>
38聽聽聽聽聽</item>
39聽聽聽</channel>
40聽</rss>
41聽
42聽
By:border