这是我的以下计划。
可以访问URL,但为什么我会收到java.io.FileNotFoundException?
public class TestGet {
private static URL source;
public static void main(String[] args) {
doGet();
}
public static void doGet() {
try {
source = new URL("http://localhost:8080/");
URLConnection connection = source.openConnection();
connection.connect();
BufferedReader rdr =new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuffer b = new StringBuffer();
String line = null;
while (true) {
line = rdr.readLine();
if (line == null)
break;
b.append(line);
}
} catch (Exception e) {
System.err.println(e.toString());
}
}
}
java.io.FileNotFoundException:http://localhost:8080/