title: how to search for a file in windows using java
body: <p>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</p>
  
  <pre><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 -&gt; " + f);             
    }     
  }
  </code></pre>
  
  <p>but I got an exception saying </p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Any suggestions on this?</p>