十分钟年华老去
--为了理想、生命和爱情
登录
注册
全站
当前博客
空间
博客
好友
相册
留言
用户操作
[即时聊天]
[发私信]
[加为好友]
十分钟年华老去
ID:zdsdiablo
共
93753
次访问,排名
987
好友
23
人,关注者
35
人
zdsdiablo的文章
原创 94 篇
翻译 0 篇
转载 25 篇
评论 66 篇
十分钟年华老去的公告
生命如水般流逝,十分钟,真的那么短暂而灿烂。 但愿那辉煌的片段里,有你我的相助,相识。
最近评论
zdsdiablo:
If you also saw these error message, you will know that.
lqefn:
What's this?
lovekatherine:
被标题迷惑了
yang2003:
没看懂
zdsdiablo:
就是因为网上没找到,所以我才决定写一下的,方便大家嘛。
文章分类
java最爱
(RSS)
net路程
(RSS)
RSS阅读器
(RSS)
操作系统
(RSS)
评天论地
(RSS)
算法的思考
(RSS)
心情随笔
(RSS)
收藏
网摘技术篇
——我的所见所闻
相册
空白
[ 博客 ]
天天想你的我
(RSS)
慕容剑朔
(RSS)
[ 视野 ]
java汇总
操作系统
chinaunix
代理服务
cnproxy
外国代理
电子教程
apache
电子书巨多巨好
维维软件园
技术论坛
chinajavaworld
gceclub.sun
javafan
javaresearch
kissjava
matrix
中国DotNet俱乐部
开源项目
apache
java业内新闻
java游戏开源
Jogl
存档
2008年09月(3)
2008年07月(2)
2008年04月(1)
2008年03月(1)
2008年01月(1)
2007年12月(1)
2007年11月(1)
2007年10月(1)
2007年06月(2)
2007年05月(2)
2007年04月(3)
2007年03月(2)
2007年02月(1)
2007年01月(1)
2006年12月(2)
2006年11月(2)
2006年10月(4)
2006年09月(1)
2006年08月(1)
2006年07月(1)
2006年06月(4)
2006年05月(3)
2006年04月(3)
2006年03月(2)
2006年02月(4)
2006年01月(7)
2005年12月(4)
2005年11月(4)
2005年10月(10)
2005年09月(9)
2005年08月(10)
2005年07月(1)
2005年06月(1)
2005年03月(1)
2004年12月(1)
软件项目交易
订阅我的博客
最有用的东西,看看这个start就全有了
收藏
新一篇: 再探游戏--天赐脚本
|
旧一篇: 探索java游戏
接上回书
今天刚巧有空,就把代码传上来看看,开发这个rss阅读的东东,真正有价值的地方只有几行而已,其他都是些swing的应用,画都画的出来。
/** */
/**
*
*/
package
alex.rssbrowse.control;
import
alex.rssbrowse.view.
*
;
import
com.sun.syndication.feed.synd.SyndFeed;
import
com.sun.syndication.feed.synd.SyndEntry;
import
com.sun.syndication.io.SyndFeedInput;
import
com.sun.syndication.io.XmlReader;
import
java.net.
*
;
import
java.util.
*
;
/** */
/**
*
@author
dozhan
*
*/
public
class
Start
...
{
//
just first test
public
static
void
test()
...
{
String str
=
"
http://blog.csdn.net/zdsdiablo/Rss.aspx
"
;
boolean
ok
=
false
;
try
...
{
URL feedUrl
=
new
URL(str);
SyndFeedInput input
=
new
SyndFeedInput();
SyndFeed feed
=
input.build(
new
XmlReader(feedUrl));
ListIterator lit
=
feed.getEntries().listIterator();
while
(lit.hasNext())
...
{
SyndEntry se
=
(SyndEntry) lit.next();
System.out.println(
"
题目:
"
+
se.getTitle());
System.out.println(
"
作者:
"
+
se.getAuthor());
System.out.println(
"
备注:
"
+
se.getDescription().getValue());
}
//
System.out.println(feed);
ok
=
true
;
}
catch
(Exception ex)
...
{
ex.printStackTrace();
System.out.println(
"
ERROR:
"
+
ex.getMessage());
}
if
(
!
ok)
...
{
System.out.println();
System.out
.println(
"
FeedReader reads and prints any RSS/Atom feed type.
"
);
System.out
.println(
"
The first parameter must be the URL of the feed to read.
"
);
System.out.println();
}
}
public
static
void
main(String[] args)
...
{
System.out.println(
"
Start...
"
);
IOConfiguration.init();
GUIBuilder gui
=
new
GUIBuilder();
gui.setVisible(
true
);
}
}
测试的时候把main里面的东西都去掉,然后去运行那个test()就能发现,爽啊,网上的东西都能读到啊。
如果读不到,可能是你要设置一下代理才行
下面这段代码是我把代理的配置放到了一个xml文件里,只做测试的话可以手写一个配置上去
package
alex.rssbrowse.control;
import
java.io.FileWriter;
import
java.io.IOException;
import
java.util.Properties;
import
org.jdom.Document;
import
org.jdom.Element;
import
org.jdom.JDOMException;
import
org.jdom.input.SAXBuilder;
import
org.jdom.output.Format;
import
org.jdom.output.XMLOutputter;
/** */
/**
*
@author
dozhan
*
*/
public
class
IOConfiguration
...
{
public
static
String HOST
=
"
proxyHost
"
;
public
static
String PORT
=
"
proxyPort
"
;
public
static
String SET
=
"
proxySet
"
;
public
static
String path
=
"
alex/rssbrowse/res/user.xml
"
;
public
static
void
init()
...
{
Properties prop
=
System.getProperties();
if
(getProxyConfiguration(SET).equalsIgnoreCase(
"
true
"
))
...
{
String host
=
getProxyConfiguration(HOST);
String port
=
getProxyConfiguration(PORT);
if
(host
!=
null
&&
port
!=
null
)
...
{
prop.put(
"
http.proxyHost
"
, host);
prop.put(
"
http.proxyPort
"
, port);
}
}
else
...
{
prop.put(
"
http.proxyHost
"
,
""
);
prop.put(
"
http.proxyPort
"
,
""
);
}
}
public
static
String getProxyConfiguration(String child)
...
{
SAXBuilder builder
=
new
SAXBuilder();
try
...
{
Document read_doc
=
builder.build(path);
Element stu
=
read_doc.getRootElement();
Element proxy
=
stu.getChild(
"
proxy
"
);
if
(proxy
!=
null
&&
child
!=
null
)
...
{
Element proxyHost
=
proxy.getChild(child);
if
(proxyHost
!=
null
)
...
{
return
proxyHost.getText();
}
}
}
catch
(JDOMException e1)
...
{
e1.printStackTrace();
}
catch
(IOException e1)
...
{
e1.printStackTrace();
}
return
""
;
}
public
static
void
setProxyConfiguration(String child, String newText)
...
{
SAXBuilder builder
=
new
SAXBuilder();
try
...
{
Document document
=
builder.build(path);
Element stu
=
document.getRootElement();
Element proxy
=
stu.getChild(
"
proxy
"
);
if
(proxy
!=
null
&&
child
!=
null
)
...
{
Element proxyHost
=
proxy.getChild(child);
if
(proxyHost
!=
null
)
...
{
proxyHost.setText(newText);
}
}
XMLOutputter xmlOut
=
new
XMLOutputter(Format.getPrettyFormat());
xmlOut.output(document, System.out);
FileWriter writer
=
new
FileWriter(path);
xmlOut.output(document, writer);
writer.close();
}
catch
(JDOMException e1)
...
{
e1.printStackTrace();
}
catch
(IOException e1)
...
{
e1.printStackTrace();
}
IOConfiguration.init();
}
}
发表于 @
2006年10月30日 17:10:00
|
评论(
loading...
)
|
编辑
新一篇: 再探游戏--天赐脚本
|
旧一篇: 探索java游戏
评论
#
xinheqishi 发表于2006-10-31 09:14:00 IP: 218.19.207.*
学到了新东西,谢谢楼主。
#
AndyLuo
发表于2006-10-31 23:46:00 IP: 218.22.21.*
import com.sun.syndication.io.SyndFeedInput;以后不一定还有,可能会提到java包里
发表评论
姓 名:
主 页:
校验码:
看不清,换一张
当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击
登录