Код: Выделить всё
SocketAddress proxyAddr = new InetSocketAddress("1.1.1.1", 12345);
Proxy pr = new Proxy(Proxy.Type.SOCKS, proxyAddr);
try {
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(pr);
con.setConnectTimeout(proxyTimeout * 1000);
con.setReadTimeout(proxyTimeout * 1000);
con.connect();
System.out.println(con.usingProxy());
} catch (IOException ex) {
Logger.getLogger(Enter.class.getName()).log(Level.SEVERE, null, ex);
}
Подробнее здесь: https://stackoverflow.com/questions/569 ... ks-in-java