import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
import java.util.Base64;

public class Main {
    public static void main(String[] args) throws Exception {
        try {
            String proxyHost = "us.swiftproxy.net";
            int proxyPort = 7878;
            Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
            String username = "username_custom_zone_us";
            String password = "password";
            String credentials = username + ":" + password;
            URL url = new URL("http://ipinfo.io");
            HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
            connection.setRequestMethod("GET");
            connection.setRequestProperty("Proxy-Authorization", "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes()));
            int responseCode = connection.getResponseCode();
            System.out.println("Response Code: " + responseCode);
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();
            System.out.println((response.toString()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}