My Controller method (which has a method to list the files, from a path mentioned in the property file, on JSP)
private String[] getFileListing(String servers) throws IOException {
Properties prop = new Properties();
String propFileName = "config.properties";
InputStream input = getClass().getClassLoader().getResourceAsStream(propFileName);
prop.load(input);
if (servers.equals("MS1")) {
File f = new File(prop.getProperty("path.MS1"));
String[] list = f.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".txt")||name.endsWith(".log");
}
});
return list;
} else {
File f = new File(prop.getProperty("path.MS2"));
String[] list = f.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".txt")||name.endsWith(".log");
}
});
return list;
}
}
I want to display the log files with common extensions like- .txt or .log But the system creates files with .1 .2 .3 extensions also.
- Is there a clear method to include all these file-type extensions as well?
- If not, then how to display all file "excluding" some file types in the directory. (I would want to exclude some other system generated files from the directory).
Thanks!