I have a very simple method that scans the directory structure to perform validation. Scanning is as follows:
File file = new File(initpath); for(File hex : file.listFiles(new HexagonNameFilter())) { for(File wall : hex.listFiles()) { for(File shelf : wall.listFiles()) { for(File book : shelf.listFiles()) {
The method is called many times during program execution.
Directly (which means at some unpredictable point in the scanning process), I get a java.lang.NullPointerException with a stack trace pointing to one of the for statements (which one is also inconsistent). This is not instructive. I was thinking of passing FilenameFilters into three calls to listFiles (), but I can't figure out how this would help.
source share