I am trying to find all of the files that are named, in the directory that I have chosen. The code that I have works when I do something like C:\Program Files, or C:\Users. But when I do c:/ I get stuck in the recycle bin and get a java.lang.NullPointerException
and stops at c:\$Recycle.Bin\S-1-5-21-1478355014-127360780-1969717230-1002144.
public void DirectorySerch(String target, String dirName){
    File f = new File(dirName); System.out.println("H");
    if(!f.isDirectory()){
        throw new IllegalArgumentException("that is not a valid directory");
    }
    for(File folderItem : f.listFiles()){
        if(folderItem.isDirectory()){
            System.out.println(folderItem.getAbsolutePath());
            if(!folderItem.equals("")){
                DirectorySerch(target,folderItem.getPath());
            }
            // Return the result if it is not empty
            /*  if (!result.equals(folderItem.getName())){
            files[filesFounfd] = folderItem.getAbsolutePath();
            filesFounfd++;
            }*/
        }else{
            if(folderItem.getName().equals(target)){
                files[filesFounfd] = folderItem.getAbsolutePath();
                System.out.println(folderItem.getAbsolutePath());
                filesFounfd++;
            }
        }        
    }
}
What can I do to not get this issue as it works in cases when it does not have to deal with the recycle bin?
 
     
     
    