(Java) HTTP Download from URL with IP Address and Port
Downloads a file from a URL using an IP address and port.
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[])
{
// 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";
boolean 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!");
}
}
|