本文範例來自 http://stackoverflow.com/questions/12405159/how-to-get-data-from-a-url

 

import java.net.*;
import java.io.*;

public class URLConnectionReader {
    public static void main(String[] args) throws Exception {
        URL oracle = new URL("http://www.oracle.com/");
        URLConnection yc = oracle.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(
                                yc.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) 
            System.out.println(inputLine);
        in.close();
    }
}

 

 

arrow
arrow

    痞客興 發表在 痞客邦 留言(0) 人氣()