i want to search for a file in windows just by giving the name of the file,intially i tried to list out all files using this piece of code
File[] files = File.listRoots();
for(File f : files){
parseAllFiles(f.getPath());
}
...
public static void parseAllFiles(String parentDirectory){
File[] filesInDirectory = new File(parentDirectory).listFiles();
for(File f : filesInDirectory){
if(f.isDirectory()){
parseAllFiles(f.getAbsolutePath());
}
System.out.println("Current File -> " + f);
}
}
but I got an exception saying
Exception in thread "main" java.lang.NullPointerException
at fileoper.parseAllFiles(fileoper.java:24)
at fileoper.parseAllFiles(fileoper.java:26)
at fileoper.parseAllFiles(fileoper.java:26)
at fileoper.main(fileoper.java:19)
Any suggestions on this?