- 浏览: 616009 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
xianzi_2008:
xianzi_2008 写道楼主请教下,我缓存了一个List& ...
Ehcache -
xianzi_2008:
楼主请教下,我缓存了一个List<Bean>对象, ...
Ehcache -
jsdsh:
收藏好.五个字
hibernate之one-to-many详细 -
Tlife:
好!!!!
hibernate------HQL总结 -
yanqingluo:
例子很恰当。
观察者模式
Rome: http://wiki.java.net/bin/view/Javawsxml/Rome
Rome是 java.net 上的一个开源项目,为什么叫Rome呢,按它的介绍上的说法,有个“条条大路通罗马”的意思,有些RSS的意味。Rome可能是 sun 公司从自己某个子项目中抽离出来的,package和类的命名就象j2sdk一样感觉规范。功能上支持RSS的所有版本及 Atom 0.3(Atom是和RSS类似的一种内容聚合的方式)。Rome 本身是提供API和功能实现.
package com.itfly;
import com.sun.syndication.io.impl.DateParser;
/**
* 读取解析一个远程RSS
* RomeReadByRemote.java
*
* @author mahaibo
* @version $Revision$
*
* @hibernate.class lazy="true" table="RomeReadByRemote"
*/
public class RomeReadByRemote {
public static void main(String[] args)
{
try
{
//如果程序位于防火墙后面,就需要在程序中加上一些Proxy设置。
java.util.Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "wsay.net");
systemSettings.put("http.proxyPort", "8080");
System.setProperties(systemSettings);
//有时候,可能会遇到“java.io.IOException: Server returned HTTP response code: 403 for URL”的错误信息。通常是因为服务器的安全设置不接受Java程序作为客户端访问,解决方案是设置客户端的User Agent, 示例代码如下:
String urlStr = "http://blogsearch.google.com/blogsearch_feeds?hl=en&q=feedsky&ie=utf-8&num=10&output=rss";
java.net.URLConnection feedUrl = new java.net.URL(urlStr).openConnection();
feedUrl.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
com.sun.syndication.io.SyndFeedInput input = new com.sun.syndication.io.SyndFeedInput();
com.sun.syndication.feed.synd.SyndFeed feed = input.build(new com.sun.syndication.io.XmlReader(feedUrl));
String feedType = feed.getFeedType();//获取原feed属于哪种格式
System.out.println(feedType);
java.util.List list = feed.getEntries();
for (int i=0; i< list.size(); i++) {
com.sun.syndication.feed.synd.SyndEntry entry = (com.sun.syndication.feed.synd.SyndEntry)list.get(i);
String entryTitle = entry.getLink();
System.out.println(entry.getPublishedDate());
System.out.println(entry.getTitle());
System.out.println(entry.getLink());
System.out.println(entry.getAuthor());
System.out.println(entry.getAuthor());
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
package com.itfly;
import java.io.File;
import java.io.PrintWriter;
import com.sun.syndication.io.SyndFeedOutput;
/**
* 读取解析一个远程RSS,并写入到一个本地文件里
* RomeReadByRemote.java
*
* @author mahaibo
* @version $Revision$
*
* @hibernate.class lazy="true" table="RomeReadByRemote"
*/
public class RomeReadAndWriteByRemote {
private static final String feedType = "rss_1.0";
public static void main(String[] args)
{
try
{
java.util.Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "mywebcache.com");
systemSettings.put("http.proxyPort", "8080");
System.setProperties(systemSettings);
String urlStr = "http://blogsearch.google.com/blogsearch_feeds?hl=en&q=feedsky&ie=utf-8&num=10&output=rss";
java.net.URLConnection feedUrl = new java.net.URL(urlStr).openConnection();
feedUrl.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//读取一个远程的Rss文件
com.sun.syndication.io.SyndFeedInput input = new com.sun.syndication.io.SyndFeedInput();
com.sun.syndication.feed.synd.SyndFeed feed = input.build(new com.sun.syndication.io.XmlReader(feedUrl));
//把读取到的结果写入到到本地一个文件里
feed.setFeedType(feedType);//设置转换的类型后再保存到另一个文件
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,new File("c:/pic/1.xml"));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
package com.itfly;
import java.io.File;
import java.io.PrintWriter;
import com.sun.syndication.io.SyndFeedOutput;
/**
* 读取解析一个本地的RSS
* RomeReadByRemote.java
*
* @author mahaibo
* @version $Revision$
*
* @hibernate.class lazy="true" table="RomeReadByRemote"
*/
public class RomeReadByLocal {
private static final String feedType = "rss_2.0";
public static void main(String[] args)
{
try
{
//读取解析本地的一个Rss文件
com.sun.syndication.io.SyndFeedInput input = new com.sun.syndication.io.SyndFeedInput();
com.sun.syndication.feed.synd.SyndFeed feed = input.build(new File("c:/pic/1.xml"));
System.out.println(feed.getFeedType());//获得原 rss是哪种格式
//在控制台输出
SyndFeedOutput output = new SyndFeedOutput();
feed.setFeedType(feedType);//以哪种格式输出feed,如果这里不设置以哪种格式输出,会以它原来的格式输出
output.output(feed, new PrintWriter(System.out));
// java.util.List list = feed.getEntries();
// for (int i=0; i< list.size(); i++) {
// com.sun.syndication.feed.synd.SyndEntry entry = (com.sun.syndication.feed.synd.SyndEntry)list.get(i);
//
//
// String entryTitle = entry.getLink();
// System.out.println(entry.getPublishedDate());
// System.out.println(entry.getTitle());
// System.out.println(entry.getLink());
// System.out.println(entry.getAuthor());
// System.out.println(entry.getAuthor());
//
// }
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
package com.itfly;
import java.io.File;
import java.io.PrintWriter;
import com.sun.syndication.io.SyndFeedOutput;
/**
* 读取解析一个本地的RSS,并写入另一个文件里
* RomeReadByRemote.java
*
* @author mahaibo
* @version $Revision$
*
* @hibernate.class lazy="true" table="RomeReadByRemote"
*/
public class RomeReadAndWriteByLocal {
public static void main(String[] args)
{
try
{
//读取解析本地的一个Rss文件
com.sun.syndication.io.SyndFeedInput input = new com.sun.syndication.io.SyndFeedInput();
com.sun.syndication.feed.synd.SyndFeed feed = input.build(new File("c:/pic/1.xml"));
//写入到另一个文件里
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, new File("c:/pic/2.xml"));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
package com.itfly;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndFeedImpl;
import com.sun.syndication.io.SyndFeedOutput;
/**
* 烧制(合并)作2个远程的RSS
* RomeBurnByRemote.java
*
* @author mahaibo
* @version $Revision$
*
* @hibernate.class lazy="true" table="RomeBurnByRemote"
*/
public class RomeBurnByRemote {
private static final String feedType = "rss_1.0";
public static void main(String[] args)
{
try
{
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(feedType);
feed.setTitle("wsay Feed");
feed.setDescription("wsay Feed");
feed.setAuthor("wsay");
feed.setLink("http://www.wsay.net");
java.util.Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "wsay.net");
systemSettings.put("http.proxyPort", "8080");
System.setProperties(systemSettings);
String urlStr = "http://blogsearch.google.com/blogsearch_feeds?hl=en&q=feedsky&ie=utf-8&num=10&output=rss";
java.net.URLConnection feedUrl = new java.net.URL(urlStr).openConnection();
feedUrl.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
String urlStr1 = "http://blog.csdn.net/mhbjava/category/173484.aspx/rss";
java.net.URLConnection feedUrl1 = new java.net.URL(urlStr1).openConnection();
feedUrl1.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
//读取某个运程的rss
com.sun.syndication.io.SyndFeedInput input = new com.sun.syndication.io.SyndFeedInput();
com.sun.syndication.feed.synd.SyndFeed feedone = input.build(new com.sun.syndication.io.XmlReader(feedUrl));
com.sun.syndication.feed.synd.SyndFeed feedtwo = input.build(new com.sun.syndication.io.XmlReader(feedUrl1));
List list = new ArrayList();
list.addAll(feedone.getEntries());
list.addAll(feedtwo.getEntries());
feed.setEntries(list);//烧制2个rss
//在控制台输出
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,new PrintWriter(System.out));
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
- src.rar (4.9 KB)
- 下载次数: 165
发表评论
-
struts备忘(转)
2008-03-31 15:14 1005=======<html:messages>=== ... -
Ehcache
2008-01-04 17:33 6936参考:http://macrochen.blogdriver. ... -
maven2介绍
2008-01-03 10:35 7522Maven2主要配置文件:pom.xml和settings.x ... -
struts2知识点备忘
2007-12-23 19:06 2222struts2标签写的form表单 1. 只有FieldErr ... -
dwr 错误:org.directwebremoting.util.CommonsLogging
2007-12-07 15:47 3385dwr遇到这种错误: org.directwebremotin ... -
XFire简单使用
2007-11-29 15:09 36791 . XFire可以认为是webservice的一个实现。 ... -
JDBM存储
2007-09-24 14:09 28001.JDBM可以把它理解成一 ... -
转:maven2
2007-09-11 10:00 15521.安装 下载Maven.目前的版本是2.0.4 ... -
eclipse plugin:EasyExplorer
2007-09-04 17:19 13931EasyExplorer 是一个类似于 Windows Ex ... -
openjms
2007-09-02 12:16 11302种模式 : 1. PTP (Point-to-Point) ... -
struts跳转问题
2007-08-07 15:46 3674web.xml <!-- Struts Action ... -
jndi,连接池,nameserver区别
2007-04-18 10:16 1420连接池就不用说了 jndi是种规范 nameserver是按照 ... -
XML-RPC 中文传递
2007-04-13 15:29 1899XML-RPC 中文传递 /** * 支持中文,Bas ... -
prototype
2007-03-14 16:52 1169new Ajax.Updater("infotop ... -
删除目录及子目录下隐藏的某个文件
2007-03-06 15:03 1391删除目录及子目录下隐藏的某个文件 del /S /A:H Th ... -
ehcache的一个bug
2007-01-23 16:55 3628java.lang.IllegalAccessError: t ... -
Rome使用简单说明二(部分关键源码分析)
2007-01-22 17:48 5064Parser部分(解析) com.sun.syndicatio ... -
hibernate 缓存
2007-01-19 17:24 1747查询缓存: 1。key(根据hql生成的sql,再加上参数,分 ... -
dwr遇到的问题解决
2007-01-10 19:05 1656问题:.Max depth exceeded when der ... -
XMLC在eclipse中的使用
2007-01-06 17:49 2170XMLC 插件 关于外部插件 ...
相关推荐
rome io包下的类之间的关系 博文链接:https://ttitfly.iteye.com/blog/49193
java使用Rome解析Rss的实例
rome-1.0.jar rome.jar 源码
Rome解析RSS必备jar
rome-1.0RC2 source,jar and doc
rome包rss使用 支持各种rss版本 XXXXX XXXXX XXXXX XXXX
ROME1.0的API文档, 该文档为自制CHM版本,没有检索.
Rome是为RSS聚合而开发的一个框架,让你可以快速的开发基于java的RSS阅读
rome开发rss jdom rom1.0
rome-1.0.jar
RSS开源框架ROME1.0下载集合 1.rome-1.0-javadoc 2.rome-1.0-sources
rome开发获取rss 配合jdom简单方便。十分的好用,欢迎下载。
rome-0.9.jar.zip
Rome是为RSS聚合而开发的一个框架,让你可以快速的开发基于java的RSS阅读,发布器,支持 RSS 0.91 Netscape RSS 0.91 Userland RSS 0.92 RSS 0.93 RSS 0.94 RSS 1.0 RSS 2.0 Atom 0.3 Atom 1.0 等标准。
rome-1.0.jar.zip
Rome是一个用于RSS和Atom提要的Java框架。框架由几个模块组成:
rome-certiorem.zip,基于罗马(过时)的JavaBuHuBub实现到HTTPS://Github. COM/ROMITOOLS/ROME