Interface FileTraverser

All Known Implementing Classes:
FileTraverserImpl

public interface FileTraverser
The FileTraverser interface provides methods to traverse directories and files asynchronously. It uses Java I/O files for file operations. This interface includes overloaded variants of the traverse method, which ultimately delegate to a single core traversal implementation that takes a File object. Additionally, it provides a method to shut down thread pools and close resources. Uses File as traversing strategy
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Shuts down thread pools and closes resources used by this file traverser instance.
    traverse(File folder)
    Asynchronously traverses the given folder, returning a list of files within the folder as a Future.
    Asynchronously traverses the directory represented by the given string path, returning a list of files within the directory as a Future.
    traverse(Path path)
    Asynchronously traverses the directory represented by the given path, returning a list of files within the directory as a Future.
  • Method Details

    • traverse

      Future<List<File>> traverse(Path path)
      Asynchronously traverses the directory represented by the given path, returning a list of files within the directory as a Future.
      Parameters:
      path - The directory path to traverse
      Returns:
      A Future containing a List of File objects representing the contents of the directory
    • traverse

      Future<List<File>> traverse(String path)
      Asynchronously traverses the directory represented by the given string path, returning a list of files within the directory as a Future.
      Parameters:
      path - The directory path (as a String) to traverse
      Returns:
      A Future containing a List of File objects representing the contents of the directory
    • traverse

      Future<List<File>> traverse(File folder)
      Asynchronously traverses the given folder, returning a list of files within the folder as a Future. This is the core method where the traversing logic happens. The other two overloaded variants transform their respective input parameters into a File object and then invoke this method.
      Parameters:
      folder - The folder to traverse
      Returns:
      A Future containing a List of File objects representing the contents of the folder
    • shutdownThreadPool

      void shutdownThreadPool()
      Shuts down thread pools and closes resources used by this file traverser instance. This method should be called when the traverser is no longer needed to ensure that all threads are properly shut down and resources are released.