是否可以在 BlueJ 中打开网址。 例如,在 PHP 中我可以使用函数 file_get_contents()
BlueJ 中有相同的东西吗?
最佳答案
您需要了解如何使用缓冲读取器以及在 Java 中使用 URL 对象。
基本上是这样的:
URL url = new URL("http://myurl.com");
URLConnection conn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String input = "";
while((input = reader.readLine())!=null) {
System.out.println(input);
}
关于java - 在 BlueJ 中打开网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9915643/