I wanted to get all fileNames present on ftp with .xls extension.
Hence i written following code:
FTPClient ftp = new FTPClient();
FTPFile[] downloadFiles = null;
try {
ftp.connect(Ftp_Path);
ftp.login(ftpUserID, ftpPassword);
downloadFiles = ftp.listFiles();
xlsFiles = new ArrayList<String>();
for(FTPFile i : downloadFiles) {
if(i.toString().endsWith(".xls")) {
xlsFiles.add(i.toString());
}
}
} catch (Exception e) {
e.printStackTrace();
}
I have made sure that files are present on ftp:
But getting error on line:
downloadFiles = ftp.listFiles();
I followed syntax from :
http://kodejava.org/how-do-i-get-list-of-files-from-ftp-server/
But getting error:
java.lang.NullPointerException
at com.amazonaws.mws.samples.ImportRulesPropertyClass.GetFileList(ImportRulesPropertyClass.java:39)
at com.amazonaws.mws.samples.ManageReportScheduleSample.main(ManageReportScheduleSample.java:74)