下面的程序为URL类的应用,请填空把程序补充完整。 import java.net.*; import java.io.*; public class URLTest { public static void main(String[] args) { URL url = null; InputStream is; try { url = new URL("http://www.xhu.edu.cn");
时间: 2024-04-26 07:25:38 浏览: 141
java.net.URL测试代码
5星 · 资源好评率100%
is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
阅读全文