1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
import java.net.*;
import java.io.*;
import java.util.*;
public class URLReader {
public static void main(String[] args) throws Exception {
// Configure proxy ...
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "xxx.xxx.xxx.xxx");
System.setProperty("http.proxyPort", "80");
System.setProperty("http.proxyType", "4");
// Open URL ...
URL url = new URL("http://www.google.com/");
BufferedReader in = new BufferedReader (
new InputStreamReader (
url.openStream ()
)
);
// Read it ...
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
} |
Partager