import java.io.*;
import java.net.URL;
import java.net.URLConnection;
public class Rough_Program
{
public static void main(String[] args) throws IOException
{
String inputLine = null;
String contant = null;
System.setProperty("java.net.useSystemProxies", "true");
System.setProperty("http.proxyHost", "10.10.10.1");
System.setProperty("http.proxyPort", "3128");
URL oracle = new URL("https://www.google.co.in/search?q=Old%20Trafford");
StringBuffer str1 = new StringBuffer();
URLConnection yc = oracle.openConnection();
yc.addRequestProperty("User-Agent", "Mozilla/4.76");
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
while ((inputLine = in.readLine()) != null) {
str1.append(inputLine);
}
contant = str1.toString();
System.out.println(contant);
}
}
答案 0 :(得分:0)
尝试为https
添加代理设置:
System.setProperty("https.proxyHost", "10.10.10.1");
System.setProperty("https.proxyPort", "3128");