I'm trying to read a folder on a network and retrieve a list of txt files. When testing it locally in Eclipse, it works fine, however whenever I deploy it on the Apache Tomcat 7 server it returns null.
It doesn't seem to be an access right problem since the server has access to the folder I'm trying to browse. I'm not sure what is going wrong there, is it a setting on the server I need to change or something else?
private List<File> readDirectory() {
File test = new File(envMap.get(database));
List<File> files = new ArrayList<File>();
try {
files = FileListing.getFileListing(test);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<File> txtFiles = new ArrayList<File>();
if (files != null) {
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".txt")) {
txtFiles.add(file);
}
}
}
return txtFiles;
}
I used this http://www.javapractices.com/topic/TopicAction.do?Id=68 for FileListing.getFileListing
After double checking it turns out that I'm getting a FileNotFoundException: Directory does not exist
. The directory does exists and the server has access rights on it, so I'm not really sure of what to do.