code: public static void deleteFilesByRegex(File dir, String regex) {
          if(regex == null) {
              throw new DataUtilException("Filename regex can not be null");
          }
          FilenameFilter filter = new RegexFilenameFilter(regex);
          FileDeleter.deleteFiles(dir, filter);
      }
docs: Delete files in a directory matching a regular expression
  @param dir directory
  @param regex regular expression