Check the time-out on the server too. Because when you trying to download large file through JAVA some time server is giving time out exception.
here are some other example code for downloading data from server to app using FTP.here i used two list remoteFileList,localFileList to give sourse file and local file paths.
FTPClient ftpClient = new FTPClient();
ftpClient.connect(Constant.FTP_SERVER_IP);
ftpClient.login(Constant.FTP_USER_NAME, Constant.FTP_PASSWORD);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
int reply = ftpClient.getReplyCode();
if (FTPReply.isPositiveCompletion(reply)) {
System.out.println("Connection Succeeded");
for (int i = 0; i < remoteFileList.size(); i++) {
remoteFileName = remoteFileList.get(i);
localFileName = localFileList.get(i);
File localFile = new File(localFileName);
if (localFile.exists()) {
System.out.println("File Already Exists!!");
} else {
downloadFile = new FileOutputStream(localFile);
boolean isDownloaded = ftpClient.retrieveFile(remoteFileName, downloadFile);
System.out.println("Downloaded");
if (isDownloaded) {
System.out.println(" - Success.\n");
} else {
System.out.println( " - Unsuccess.\n");
}
}
if (i == remoteFileList.size() - 1 && this.DownloadType == 1) {
System.out.println("This is time to open !");
JOptionPane.showMessageDialog(this, "Image downloading completed.Please open the inspection");
}
}
} else {
ftpClient.disconnect();
}