質問: urlIn.readLine()) != null) { System.out.println(str); } // URL切断 urlIn.close(); urlCon.disconnect(); } catch (Exception ex) { ex.printStackTrace(); } } } 以下実行結果です。 URL: http://www.yahoo.co.jp/ URL: http://www.yahoo.co.jp/ java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at sun.net.NetworkClient.doConnect(NetworkClient.java:163) at sun.net.www.http.HttpClient.openServer(HttpClient.java:394) at sun.net.www.http.HttpClient.openServer(HttpClient.java:529) at sun.net.www.http.HttpClient.(HttpClient.java:233) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.http.HttpClient.New(HttpClient.java:323) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC onnection.java:837) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne ction.java:778) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection .java:703) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon nection.java:1026) at HttpUrl.main(HttpUrl.java:36)
回答: >Javaは始めたてなので何が悪いかわかりません。 コピペで済ませようなんて考え方が悪い。 基礎からやりな。