I have been trying to make this code work and also browsed stackoverflow for a while now but not able to find the answer. Hope you can help.
Trying to download a zip file from internet however it result in a zip file of 1 kb.
update: i have tried Long.MAX_VALUE, but the result is the same. I'm really not sure what is wrong. Normal text files works just file, but not zipfiles. PLease help.
private static void testDownload() {
try {
URL website = new URL("http://www.sec.gov/Archives/edgar/data/1027884/000102788418000013/0001027884-18-000013-xbrl.zip");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("C:\\0001027884-18-000013-xbrl.zip");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}catch(Exception e){
System.out.println("EXCEPTION: " + e.getMessage());
System.exit(2);
}
}