載せるプログラムだと、 エラー: 例外MalformedURLExceptionは報告されません。スローするには、捕捉または宣言する必要があります
URL theUrl = new URL(args[0]);
^
と出てしまいます。どうすればよいでしょうか?
import java.io.;
import java.net.;
public class A {
public static void main(String args[]) {
URL theUrl = new URL(args[0]);
try{
HttpURLConnection huc = (HttpURLConnection)theUrl.openConnection();
InputStream instream = huc.getInputStream();
InputStreamReader isreader = new InputStreamReader(instream);
BufferedReader bfreader = new BufferedReader(isreader);
String theLine;
do { theLine = bfreader.readLine(); if( theLine != null ) { System.out.println(theLine); } } while( theLine != null ); } catch (Exception e) { System.err.print(e); } }
}
回答2件
あなたの回答
tips
プレビュー