Why does a wildcard not work in java code below?
My request looks like http://localhost:8080/App/DataAccess?location=Dublin
rob@work:~$ ls /usr/local/CustomAppResults/Dublin/*/.history
/usr/local/CustomAppResults/Dublin/team1/.history
/usr/local/CustomAppResults/Dublin/team2/.history
/usr/local/CustomAppResults/Dublin/team3/.history
Servlet code (DataAccess.java).
(DataAccess.java:27)
refers to the for loop ..
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
File[] files = finder("/usr/local/CustomAppResults/" +
request.getParameter("location") + "/*/");
for (int i = 0; i < files.length; i++){
System.out.println(files[i].getName());
}
}
private File[] finder(String dirName) {
File dir = new File(dirName);
return dir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String filename) {
return filename.endsWith(".history");
}
});
}
Error:
The server encountered an internal error that prevented it
from fulfilling this request.
java.lang.NullPointerException
com.example.servlets.DataAccess.doGet(DataAccess.java:27)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)