code: public static <E extends Exception> boolean deleteFiles(final File dir, Try.BiPredicate<? super File, ? super File, E> filter) throws E {
          if ((dir == null) || !dir.exists()) {
              return false;
          }
  
          if (dir.isDirectory()) {
              final File[] files = dir.listFiles();
  
              if (N.isNullOrEmpty(files)) {
                  return true;
              }
  
              for (File subFile : files) {
                  if (subFile == null) {
                      continue;
                  }
  
                  if (filter == null || filter.test(dir, subFile)) {
                      if (subFile.isFile()) {
                          if (subFile.delete() == false) {
                              return false;
                          }
                      } else {
                          if (deleteAllIfExists(subFile) == false) {
                              return false;
                          }
                      }
                  } else {
                      if (subFile.isDirectory()) {
                          if (deleteFiles(subFile, filter) == false) {
                              return false;
                          }
                      }
                  }
              }
          } else {
              if (filter == null || filter.test(dir.getParentFile(), dir)) {
                  return dir.delete();
              }
          }
  
          return true;
      }
docs: Delete the specifield <code>dir</code> if it's a file or its sub files/directories if it's a directory with the specified filter.
  
  @param dir
  @param filter
  @return