Reputation: 2895
I am using appache commons method to download some files from my FTP server and I am having some issues with the zip file being corrupted. I am able to download the file and place the file in the correct folder but when I open it there are files missing and it claims it's corrupted, if I try downloading with normal .txt files it works fine.
public boolean downloadFiles(String folder, String file) throws Exception
{
File output = new File(folder + "\\" + file);
System.out.println(output);
FileOutputStream out = new FileOutputStream(output);
client.retrieveFile(file, out);
out.close();
if(output.exists())
return true;
else
return false;
}
Upvotes: 1
Views: 1469
Reputation: 361
Make sure you use binary mode for the FTP transfer. The fact that txt files work indicates that this is most likely your problem.
Upvotes: 3
Reputation: 771
The file you are downloading on java client, try opening manually going to the FTP location itself. see if the zip file is okay or not. i had similar issue and found out that zip file was corrupt. Second step would be , check the size of the zip file you are downloading and the size of the downloaded file.
Upvotes: 1