📄 -
字号:
if (args.length>=2)
{<BR>
try
{<BR>
String outputType = args[0];</DIV>
<DIV>
SyndFeed feed = new
SyndFeedImpl();<BR>
feed.setFeedType(outputType);</DIV>
<DIV>
feed.setTitle("Aggregated
Feed");<BR>
feed.setDescription("Anonymous Aggregated
Feed");<BR>
feed.setAuthor("anonymous");<BR>
feed.setLink("<A
href="http://www.anonymous.com/">http://www.anonymous.com/</A>");</DIV>
<DIV>
List entries = new
ArrayList();<BR>
feed.setEntries(entries);</DIV>
<DIV>
for (int i=1;i<args.length;i++)
{<BR>
URL inputUrl = new URL(args[i]);</DIV>
<DIV>
SyndFeedInput input = new
SyndFeedInput();<BR>
SyndFeed inFeed = input.build(new
XmlReader(inputUrl));</DIV>
<DIV>
entries.addAll(inFeed.getEntries());</DIV>
<DIV>
}</DIV>
<DIV>
SyndFeedOutput output = new
SyndFeedOutput();<BR>
output.output(feed,new
PrintWriter(System.out));</DIV>
<DIV>
ok =
true;<BR>
}<BR>
catch (Exception ex)
{<BR>
System.out.println("ERROR:
"+ex.getMessage());<BR>
}<BR>
}</DIV>
<DIV> if
(!ok)
{<BR>
System.out.println();<BR>
System.out.println("FeedAggregator aggregates
different feeds into a single
one.");<BR>
System.out.println("The first parameter must be
the feed type for the aggregated
feed.");<BR>
System.out.println(" [valid values are: rss_0.9,
rss_0.91U, rss_0.91N, rss_0.92, rss_0.93,
]");<BR>
System.out.println("
[
rss_0.94, rss_1.0, rss_2.0 & atom_0.3
]");<BR>
System.out.println("The second to last parameters
are the URLs of feeds to
aggregate.");<BR>
System.out.println();<BR>
}<BR> }</DIV>
<DIV>}<BR>3:将动态生成的RSS存盘,形成静态RSS<BR>package
com.sun.syndication.samples;</DIV>
<DIV>import
com.sun.syndication.feed.synd.*;<BR>import
com.sun.syndication.io.SyndFeedOutput;</DIV>
<DIV>import java.io.FileWriter;<BR>import
java.io.Writer;<BR>import
java.text.DateFormat;<BR>import
java.text.SimpleDateFormat;<BR>import
java.util.ArrayList;<BR>import
java.util.List;</DIV>
<DIV>/**<BR> * It creates a feed and writes
it to a file.<BR> * <p><BR> *
@author Alejandro
Abdelnur<BR> *<BR> */<BR>public class
FeedWriter {</DIV>
<DIV> private static final
String DATE_FORMAT = "yyyy-MM-dd";</DIV>
<DIV> public static void
main(String[] args)
{<BR>
boolean ok =
false;<BR>
if (args.length==0)
{<BR>
try
{<BR>
String feedType =
"rss_2.0";//指定rss类型<BR>
String fileName = "F:\\ss.xml";//静态rss存放目录</DIV>
<DIV>
DateFormat dateParser = new
SimpleDateFormat(DATE_FORMAT);</DIV>
<DIV> //feed是通过SyndFeedImpl的实例 <BR>
SyndFeed feed = new
SyndFeedImpl();<BR>
feed.setFeedType(feedType);</DIV>
<DIV>
feed.setTitle("Sample Feed (created with
Rome)");<BR>
feed.setLink("<A
href="http://rome.dev.java.net/">http://rome.dev.java.net/</A>");<BR>
feed.setDescription("This feed has been created
using Rome (Java syndication
utilities");<BR> <BR> //entries就是item集合<BR>
List entries = new
ArrayList();<BR> //一个entry就是一个item<BR>
SyndEntry
entry;<BR>
SyndContent
description;<BR> <BR> //第一个item<BR>
entry = new
SyndEntryImpl();<BR>
entry.setTitle("Rome
v1.0");<BR>
entry.setLink("<A
href="http://wiki.java.net/bin/view/Javawsxml/Rome01">http://wiki.java.net/bin/view/Javawsxml/Rome01</A>");<BR>
entry.setPublishedDate(dateParser.parse("2004-06-08"));<BR>
description = new
SyndContentImpl();<BR>
description.setType("text/plain");<BR>
description.setValue("Initial release of
Rome");<BR>
entry.setDescription(description);<BR>
entries.add(entry);</DIV>
<DIV> //第二个item<BR>
entry = new
SyndEntryImpl();<BR>
entry.setTitle("Rome
v2.0");<BR>
entry.setLink("<A
href="http://wiki.java.net/bin/view/Javawsxml/Rome02">http://wiki.java.net/bin/view/Javawsxml/Rome02</A>");<BR>
entry.setPublishedDate(dateParser.parse("2004-06-16"));<BR>
description = new
SyndContentImpl();<BR>
description.setType("text/xml");<BR>
description.setValue("Bug fixes,
<xml>XML</xml> minor API changes and
some new
features");<BR>
entry.setDescription(description);<BR>
entries.add(entry);</DIV>
<DIV> //第三个item<BR>
entry = new
SyndEntryImpl();<BR>
entry.setTitle("Rome
v3.0");<BR>
entry.setLink("<A
href="http://wiki.java.net/bin/view/Javawsxml/Rome03">http://wiki.java.net/bin/view/Javawsxml/Rome03</A>");<BR>
entry.setPublishedDate(dateParser.parse("2004-07-27"));<BR>
description = new
SyndContentImpl();<BR>
description.setType("text/html");<BR>
description.setValue("<p>More Bug fixes, mor
API changes, some new features and some Unit
testing</p>"+<BR>
"<p>For details check the <a href=\"<A
href='http://wiki.java.net/bin/view/Javawsxml/RomeChangesLog#RomeV03\">Changes'>http://wiki.java.net/bin/view/Javawsxml/RomeChangesLog#RomeV03\">Changes</A>
Log</a></p>");<BR>
entry.setDescription(description);<BR> <BR> //将所有item存入entries<BR>
entries.add(entry);<BR> <BR> //将entries加入channel<BR>
feed.setEntries(entries);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -