I am trying to upload files to a FTP Server in a Java class. I use apache library: org.apache.commons.net.ftp.FTPClient. The upload function works fine until I try to upload a XLS (Excel) file. In particular, when I upload it, the file is uploaded, but it seems to be corrupted. In fact its size is different from the original size and when I try to open it, it doesn't open correctly and doesn't show all the data.
Here is a portion from the code I use:
FTPClient ftpClient = new FTPClient();
File[] fileList;fileList = localFilePath.listFiles();
for (File file : fileList) {
String fileName = file.getName();
FileInputStream fileInputStream = new FileInputStream(file);
ftpClient.storeFile(fileName, fileInputStream);
fileInputStream.close();
}
Thank you very much for any kind of help.