code: public static List<File> getMatchingFiles(File root, String filterExpr) {
          if (root == null)
              return Collections.emptyList();
  
          File fileList[];
          FileFilter filter;
  
          if (filterExpr == null)
              filter = new FilesOnly();
          else
              filter = new FilesOnlyFilter(filterExpr);
  
          fileList = root.listFiles(filter);
  
          if (fileList == null)
              return Collections.emptyList();
          else {
              if (fileList.length > 1) {
                  Arrays.sort(fileList, new SortByFileName());
              }
              return Arrays.asList(fileList);
          }
      }
docs: Get a list of Files from the given path that match the provided filter;
  not recursive.
  
  @param root
  base directory to look for files
  @param filterExpr
  the regular expression to match, may be null
  @return List of File objects; List will be empty if root is null