首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

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

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

我用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)         

热点排行