package cn.edu.tju;
import java.io.InputStream;
import java.net.*;
public class ProxyTest {
static String dest="https://x.com/";
static String proxyUrl="127.0.0.1";//
static int proxyPort=8580;
public static void main(String[] args) throws Exception {
URL url = new URL(dest);
//创建代理服务器
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyUrl, proxyPort));
//连接目标服务器
HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
connection.setConnectTimeout(60000);
InputStream is = connection.getInputStream();
byte[] bytes = new byte[4096];
is.read(bytes);
System.out.println(new String(bytes));
}
}