In the following method a part of my code is reading a list of xml files from a folder and returns the list of files. Everything works fine in eclipse but while buillding the same on jenkins, it is failing?
code snippet:
public List<File> getFileList(String dir) {
File folder = new File(dir);
List<File> FileList = new ArrayList<File>();
for (File file : folder.listFiles()) {
if (file.exists()
&& file.getName().substring(file.getName().lastIndexOf('.') + 1).contentEquals("xml")) {
FileList .add(file);
}
}
return xmlFileList;
}
error on jenkins build, it says null pointer exception
java.lang.NullPointerException
at com.akash.anand.executive.MyClass$FileReader.getFileList(MyClass.java:218)