我試圖從網頁讀取數據,我必須使用Java來完成。 當我嘗試使用Java我得到超時錯誤做在Eclipse: java.net.ConnectException:連接超時:連接 (使用HttpURLConnection類):使用c#(VS2008)的WebRequest是完全正常工作,但不是在Java(Ecplise)
URL yahoo = new URL("http://www.yahoo.com/");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
爲了瞭解在哪裏我試着用c#和VS2008做同樣的任務,並且它工作得很好,沒有時間。
我正在做這個工作,所以有一個防火牆,但我沒有關於它的信息。
這可能是什麼原因?
謝謝! Daniel
1. Java不是首字母縮寫詞。 2.您需要張貼一些源代碼,並提供其他相關信息(任何防火牆等)。 – 2010-05-25 06:28:31