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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| package test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Sms {
public static void main(String[] args) throws Exception {
String sURLString = "http://www.google.com.tw";
HttpURLConnection huc = null;
BufferedReader buReader = null;
try {
System.getProperties().setProperty("http.proxySet","true");
System.getProperties().setProperty("http.proxyHost","2.69.7774.1");
System.getProperties().setProperty("http.proxyPort", "0000");
huc = (HttpURLConnection)new URL(sURLString).openConnection();
huc.setInstanceFollowRedirects(true);
huc.setDoInput(true);
huc.setDoOutput(true);
huc.setUseCaches(false);
huc.setRequestMethod("GET");
buReader = new BufferedReader(new InputStreamReader(huc.getInputStream(), "UTF-8"));
String sLine;
while ((sLine = buReader.readLine()) != null)
System.out.println(sLine);
} catch (Exception e) {
System.out.println("Sms:" + e.toString());
} finally {
try {
if (buReader != null) buReader.close();
} catch (Exception e) {
} finally {
buReader = null;
}
huc = null;
}
}
}
|