> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.aceproxies.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to use Proxies in Java code?

Sample code for using a proxy in Java code:

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

 

classProxyTest {
  public static void main(String[] args) throws Exception {
    InetSocketAddressproxyAddress = new InetSocketAddress("1.1.1.1", 1234); // Set proxy IP/port.
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress);
    URL url = new URL("http://aceproxies.com/");
    URLConnectionurlConnection = url.openConnection(proxy);
    Scanner scanner = new Scanner(urlConnection.getInputStream());
    System.out.println(scanner.next());
    scanner.close();
  }
}```