Portal Home > Knowledgebase > Tutorials > How to use proxies in Java code

How to use proxies in Java code

Before using our proxies, ensure that your server IP address is authorized via the proxy control panel.

Sample code for using proxies in Java code:


import java.net.*;
import java.util.Scanner;


class ProxyTest {
  public static void main(String[] args) throws Exception {
    InetSocketAddress proxyAddress = new InetSocketAddress("", 8800); // Set proxy IP/port.
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress);

    URL url = new URL("http://checkip.instantproxies.com/");
    URLConnection urlConnection = url.openConnection(proxy);
    Scanner scanner = new Scanner(urlConnection.getInputStream());

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read

Powered by WHMCompleteSolution

© InstantProxies.com. All Rights Reserved.