title: How to print list of filenames that DONT match a regex ? Java 8
body: <p>For some reason, my code will print ALL files when I want it to only print out the files that DONT match my regex pattern.. I need it to print out the files that dont match the pattern because I dont know all the possible inconsistencies there are in the file naming. MY regex represents the correct possibilities a file name can be labeled.  I checked my regex pattern on regex101 and it is correct. I am not a coder, but I am a psychology student working on a mass database.</p>
  
  <p>Ive tried making Pattern into a list pattern, and I tried putting patternList.matcher(file.getName()) into like its own Matcher variable.</p>
  
  <pre><code>    private static void checkFolder(File root, Pattern patternList) {
          for(File file : root.listFiles())
  
          if(file.isFile()){
  
              if(patternList.matcher(file.getName()).matches())
                  checkFolder(rootFolder, patternList);
              else 
                  System.out.println(file); //print if it does not match
          }
  </code></pre>
  
  <p>For example, If my code looks at these file names:</p>
  
  <ul>
  <li>95F Front Anger.BW </li>
  <li>95F.Front.Anger.C.Micro</li>
  <li>95F.Front.Fear.C.Micro</li>
  <li>95F.Front.Frown.BW</li>
  </ul>
  
  <p>And my regex is this:</p>
  
  <pre><code>    Pattern patternList = Pattern.compile("((\\d{1,3}(F|M)\\.(Front|Profile|Right)"
      +"\\.(Anger|Fear|Frown|Smile)\\.(BW\\.Micro|BW|C\\.Micro|C)))|"
      +"(\\d{1,3}(F|M)\\.(Front|Profile|Right)\\.(Neutral|Smile)\\."
      +"(C\\.Micro|C|BW\\.Micro|BW|HighLight|LowLight|MedLight)\\.(BW\\.Micro|BW|C\\.Micro|C))|"
      +"(\\d{1,3}(F|M)\\.(Selfie1|Selfie2|StudentID)\\.(C\\.Micro|C|BW\\.Micro|BW))");
  </code></pre>
  
  <p>My code should only print out 95F Front Anger.BW, because it has whitespaces instead of dots, but my code still prints out all four filenames.</p>
  
  <p>I also tried doing this:</p>
  
  <pre><code>    private static void checkFolder(File root, Pattern patternList) {
      for(File file : root.listFiles())
  
          if(file.isFile()){
  
              if(!patternList.matcher(file.getName()).matches())
              {
                 System.out.println(file); //print the file that doesnt match the regex
              }
              else
              {
              checkFolder(rootFolder, patternList);
              }    
  
  
  
          }
   }
  </code></pre>