Sun Syndication API在尝试解析特定RSS源时抛出错误

时间:2011-12-09 12:43:43

标签: java xmlreader rome syndication-feed

使用SUN联合API ROME, 我正在尝试解析以下RSS提要:

http://news.yahoo.com/rss/world;_ylt=AmPejPeRK0mzDzsOSrANm125scB_;_ylu=X3oDMTFqbTQ3ajl2BG1pdANSU1MgU2l0ZUluZGV4IFdvcmxkBHBvcwM0BHNlYwNNZWRpYVJTU0VkaXRvcmlhbA--;_ylg=X3oDMTFrM25vcXFyBGludGwDdXMEbGFuZwNlbi11cwRwc3RhaWQDBHBzdGNhdAMEcHQDc2VjdGlvbnMEdGVzdAM-;_ylv=3

以下是此代码:

import java.net.URL;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

public class Test {
    public static void main(String[] args) {
        URL url;
        XmlReader reader = null;
        SyndFeed feed;
        try {
            url = new URL(    "http://news.yahoo.com/rss/world;_ylt=AmPejPeRK0mzDzsOSrANm125scB_;_ylu=X3oDMTFqbTQ3ajl2BG1p  dANSU1MgU2l0ZUluZGV4IFdvcmxkBHBvcwM0BHNlYwNNZWRpYVJTU0VkaXRvcmlhbA--    ;_ylg=X3oDMTFrM25vcXFyBGludGwDdXMEbGFuZwNlbi11cwRwc3RhaWQDBHBzdGNhdAMEcHQDc2VjdGlvbnMEdGVzdA  M-;_ylv=3");
            reader = new XmlReader(url);
            feed = new SyndFeedInput().build(reader);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
 }

我得到以下例外:

java.io.FileNotFoundException: http://localhost/world/?format=rss
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1401)
    at com.sun.syndication.io.XmlReader.<init>(XmlReader.java:237)
    at com.sun.syndication.io.XmlReader.<init>(XmlReader.java:213)
    at Test.main(Test.java:20)

这发生在404的响应上,因为我可以在HTTPUrlConnection类中推断出,这种问题是否有解决办法?

此问题仅适用于此特定网址,是否有人知道如何解决此问题?

0 个答案:

没有答案