通过URL读取rss-java.net.ConnectException:连接超时:连接
您好,我有一个问题,我想通过该网站的URL使用rss,但我不能这样做。 例如: 错误:通过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
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());