Sample code for 30+ languages & platforms
Java

HTTP Download from URL with IP Address and Port

See more HTTP Examples

Downloads a file from a URL using an IP address and port.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();

    http.SetRequestHeader("Host","chilkatsoft.com");

    String localFilePath = "/temp/hamlet.zip";
    success = http.Download("http://107.180.46.206:80/hamlet.zip",localFilePath);
    if (success != true) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println("OK!");
  }
}