public interface Searchable
Interface for searching capabilities within files and directories
  • Method Details

    • getRootDirectory

      default File getRootDirectory(File file)
      Retrieves the root directory of the given file object
      Parameters:
      file - the file to analyze
      Returns:
      the root directory from the given file
    • containsFile

      default boolean containsFile(File parent, File search)
      Checks if the parent directory contains the specified file by filename
      Parameters:
      parent - the directory to search within
      search - the file to locate
      Returns:
      true if the file exists in the parent directory otherwise false
    • containsFile

      default boolean containsFile(File parent, String pathname)
      Checks if the parent directory contains a file matching the specified filename
      Parameters:
      parent - the directory to search within
      pathname - the filename to search for
      Returns:
      true if the file exists in the parent directory otherwise false
    • findFiles

      default Set<File> findFiles(File directory, Predicate<File> predicate) throws IOException
      Searches for files in a directory matching a specified predicate
      Parameters:
      directory - the directory to search
      predicate - the condition to filter files
      Returns:
      a set of files that match the predicate
      Throws:
      IOException - if an I/O error occurs
    • findFilesRecursive

      default Set<File> findFilesRecursive(File directory, Predicate<File> predicate) throws IOException
      Recursively searches for files in a directory matching a specified predicate
      Parameters:
      directory - the directory to search
      predicate - the condition to filter files
      Returns:
      a set of files that match the predicate
      Throws:
      IOException - if an I/O error occurs
    • countAllFilesInDirectory

      default long countAllFilesInDirectory(File dir, long length, boolean includeDirectories)
      Counts all files in a directory recursively, optionally including directories in the count
      Parameters:
      dir - the directory to count files in
      length - the starting count
      includeDirectories - flag to include directories in the count if true
      Returns:
      the total number of files and directories
    • findAllFiles

      default List<File> findAllFiles(File dir, String fileSearchPattern)
      Finds files within a directory matching a specified search pattern (regex)
      Parameters:
      dir - the directory to search
      fileSearchPattern - the regex pattern to match filenames against
      Returns:
      a list of matching files
    • findFiles

      default List<File> findFiles(String start, String[] extensions)
      Finds all files in a directory with the specified extensions
      Parameters:
      start - the starting directory
      extensions - array of file extensions to search for
      Returns:
      a list of files that match the specified extensions
    • getAllFilesFromDir

      default List<File> getAllFilesFromDir(File dir)
      Retrieves all files from a directory
      Parameters:
      dir - the directory to retrieve files from
      Returns:
      a list of files in the directory
    • getAllFilesFromDirRecursive

      default List<File> getAllFilesFromDirRecursive(File dir)
      Retrieves all files from a directory recursively
      Parameters:
      dir - the directory to retrieve files from
      Returns:
      a list of all files in the directory and its subdirectories
    • findFilesWithPrefixAndExtensionRecursive

      default List<File> findFilesWithPrefixAndExtensionRecursive(File dir, String prefix, String extension)
      Finds all files in the specified directory and subdirectories that match the given prefix and extension
      Parameters:
      dir - the directory in which to search for files
      prefix - the prefix that filenames should start with
      extension - the file extension that filenames should have
      Returns:
      a list of files that match the specified prefix and extension