1import java.net.*;
2import java.io.*;
3
4public class StaticIspProProxyExample {
5 public static void main(String[] args) throws Exception {
6 Proxy proxy = new Proxy(Proxy.Type.SOCKS,
7 new InetSocketAddress("proxy-host", 1080));
8
9 Authenticator.setDefault(new Authenticator() {
10 protected PasswordAuthentication getPasswordAuthentication() {
11 return new PasswordAuthentication(
12 "username", "password".toCharArray());
13 }
14 });
15
16 URL url = new URL("http://ip.proxxxymiron.com/");
17 HttpURLConnection connection =
18 (HttpURLConnection) url.openConnection(proxy);
19
20 try (BufferedReader reader = new BufferedReader(
21 new InputStreamReader(connection.getInputStream()))) {
22 String line;
23 while ((line = reader.readLine()) != null) {
24 System.out.println(line);
25 }
26 }
27 }
28}