I used the code provided in accepted solution of below thread to download a 500kb zip file How to download and save a file from Internet using Java?
public static File  downloadFile(String fileURL, String saveDir)
        throws IOException {
    File downloadFolder = null;
    String saveFilePath = null;
    URL url = new URL(fileURL);
   ReadableByteChannel rbc = Channels.newChannel(url.openStream());
   String    fileName = fileURL.substring(fileURL.lastIndexOf("/") + 1, fileURL.length()); 
   FileOutputStream fos = new FileOutputStream(fileName);
   saveFilePath = saveDir + File.separator + fileName;
   downloadFolder = new File(saveDir);
   downloadFolder.deleteOnExit();
   downloadFolder.mkdirs();
   FileOutputStream outputStream = new FileOutputStream(saveFilePath);
   outputStream.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
   outputStream.close();
  rbc.close();
    return new File(saveFilePath);
}
The code is able to identify the file but the the problem is , the download is incomplete. It always downloads 5KB and stops there after.
I dont want to use apache commons file untils.
 
    