I have a list of FTP files and I can only convert the first FTPFile
to File
. I am using org.apache.commons.net.ftp
library.
My code is works fine for the first time:
for (FTPFile file : files) {
if(ftpClient.sendNoOp()){
if(file.getName()!=null || !file.getName().equals("")) {
InputStream iStream=ftpClient.retrieveFileStream(file.getName());
File file2 = File.createTempFile("xml", null);
FileUtils.copyInputStreamToFile(iStream, file2);
iStream.close();
}
}
}
From this code the loop traverse only time and the FTPFile
is converted to File
and after that it will get exception which is created by null
value generated in ftpClient.retrieveFileStream(file.getName())
.
Please help.