Class FileTraverserImpl
java.lang.Object
org.pwss.io_file.FileTraverserImpl
- All Implemented Interfaces:
FileTraverser
The FileTraverseImpl class provides an implementation of the
FileTraverser
interface.
Uses File as traversing strategy-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of theFileTraverserImplclass. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidShuts down thread pools and closes resources used by this file traverser instance.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.Asynchronously traverses the directory represented by the given path, returning a list of files within the directory as a Future.
-
Constructor Details
-
FileTraverserImpl
public FileTraverserImpl()Constructs a new instance of theFileTraverserImplclass. Initializes an executor service with a fixed thread pool size and sets up a logger for this implementation.
-
-
Method Details
-
traverse
Description copied from interface:FileTraverserAsynchronously traverses the directory represented by the given path, returning a list of files within the directory as a Future.- Specified by:
traversein interfaceFileTraverser- Parameters:
path- The directory path to traverse- Returns:
- A Future containing a List of File objects representing the contents of the directory
-
traverse
Description copied from interface:FileTraverserAsynchronously traverses the directory represented by the given string path, returning a list of files within the directory as a Future.- Specified by:
traversein interfaceFileTraverser- 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
-
shutdownThreadPool
public final void shutdownThreadPool()Description copied from interface:FileTraverserShuts 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.- Specified by:
shutdownThreadPoolin interfaceFileTraverser
-
traverse
Description copied from interface:FileTraverserAsynchronously 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.- Specified by:
traversein interfaceFileTraverser- Parameters:
folder- The folder to traverse- Returns:
- A Future containing a List of File objects representing the contents of the folder
-