0

使用 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 类中推断的那样,这种问题有什么解决方法吗?

此问题仅与此特定 URL 有关,有人知道如何克服此问题吗?

4

0 回答 0