Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过URL读取rss-java.net.ConnectException:连接超时:连接_Java_Url_Rss_Websphere_Portlet - Fatal编程技术网

通过URL读取rss-java.net.ConnectException:连接超时:连接

通过URL读取rss-java.net.ConnectException:连接超时:连接,java,url,rss,websphere,portlet,Java,Url,Rss,Websphere,Portlet,您好,我有一个问题,我想通过该网站的URL使用rss,但我不能这样做。 例如: 错误: java.net.ConnectException: Connection timed out: connect 我需要在IBM网站和论坛上搜索的帮助,但没有解决问题。 招呼 若昂·索萨如果您可以通过浏览器打开,则不需要前两行: System.setProperty("https.proxyHost", "proxy.example.local"); System.setProperty("https.pr

您好,我有一个问题,我想通过该网站的URL使用rss,但我不能这样做。 例如:

错误:

java.net.ConnectException: Connection timed out: connect
我需要在IBM网站和论坛上搜索的帮助,但没有解决问题。 招呼 若昂·索萨

如果您可以通过浏览器打开,则不需要前两行:

System.setProperty("https.proxyHost", "proxy.example.local");
System.setProperty("https.proxyPort", "80");
没有
代理.example.local

当然,也要去掉这条线

InputStream stream = connection.getInputStream();
最后的代码是

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

    URL url = new URL("http://pplware.sapo.pt/feed/");
    InputStream stream = url.openStream();
    Document doc = docBuilder.parse(stream);
    System.out.println("Root element of the doc is "
            + doc.getDocumentElement().getNodeName());

它对我有效。

您两次声明一个变量。这是代码编译吗?
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();

    URL url = new URL("http://pplware.sapo.pt/feed/");
    InputStream stream = url.openStream();
    Document doc = docBuilder.parse(stream);
    System.out.println("Root element of the doc is "
            + doc.getDocumentElement().getNodeName());