集册 Java实例教程 从URL读取

从URL读取

欢马劈雪     最近更新时间:2020-01-02 10:19:05

446
从URL读取

import java.net.*;

import java.io.*;/**来 自 n o w j a v a . c o m**/


public class URLReader {

    public static void main(String[] args) throws Exception {


        URL oracle = new URL("http://www.oracle.com/");

        BufferedReader in = new BufferedReader(new InputStreamReader(

                oracle.openStream()));


        String inputLine;

        while ((inputLine = in.readLine()) != null)

            System.out.println(inputLine);

        in.close();

    }

}


展开阅读全文