专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Java Exception

java.net.SocketException: Unexpected end of file from server

发布时间:2010-06-05 12:25:29 文章来源:www.iduyao.cn 采编人员:星星草

我用rome 0.9 读取rss信息时出现以下错误,这个错误比较怪,有时候我重启tomcat读取就正常了

package FeedReader;
import java.util.ArrayList;
import java.util.Date;
import java.net.URL;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndContent;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
public class FeedReader {
public static ArrayList getList(String URL)throws Exception{
ArrayList arrayList=new ArrayList();
if(URL!=null&&!URL.equals( " ")){
arrayList=reader(URL);
}
return arrayList;
}
private static ArrayList reader(String URL)throws Exception{
ArrayList arrayList=new ArrayList();
try{
URL feedUrl = new URL(URL);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
java.util.List entries=feed.getEntries();
for(java.util.ListIterator li=entries.listIterator();li.hasNext();){
SyndEntry entryImpl=(SyndEntry)li.next();
String title=entryImpl.getTitle();
Date postDate=entryImpl.getPublishedDate();
String url=entryImpl.getLink();
String content=entryImpl.getDescription().getValue();
//System.out.println( "\n更新时间: "+postDate);
Article article=new Article();
article.setTitle(title);
article.setDate(postDate);
article.setURL(url);
article.setSummary(content);
arrayList.add(article);
}
}catch(Exception e){
e.printStackTrace();
System.out.println( "错了 "+e);
}
return arrayList;
}
}

错误提示如下:
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:684)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:554)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:682)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:554)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:940)
at com.sun.syndication.io.XmlReader. <init> (XmlReader.java:174)
at com.sun.syndication.io.XmlReader. <init> (XmlReader.java:151)     

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: