Package organizers
Class DirectoryHandler
java.lang.Object
organizers.DirectoryHandler
A utility class for searching and retrieving files within a directory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFilesInDirectory(File directory, List<String> filePaths) Recursively adds the file paths of all files within the specified directory and its subdirectories to the filePaths list.static voidcleanDirectory(String pathToNeededCleanedDirectory) Cleans the specified directory by deleting its files and subdirectories recursively.getFilesInDirectory(String directoryName) Retrieves the file paths of all files within the specified directory and its subdirectories.static booleanChecks if the specified directory contains any files.static voidmoveMapFileToErrorDirectory(String mapFilePath, int exitCode) Moves a map file from the overall actual directory (or other place) to an error directory based on its exit code.voidsearchFiles(File directory, String directoryName, List<String> filePaths) Recursively searches for the specified directory within the given directory and its subdirectories.
-
Constructor Details
-
DirectoryHandler
public DirectoryHandler()
-
-
Method Details
-
getFilesInDirectory
Retrieves the file paths of all files within the specified directory and its subdirectories.- Parameters:
directoryName- the name of the directory to search for- Returns:
- a list of file paths as strings
-
addFilesInDirectory
Recursively adds the file paths of all files within the specified directory and its subdirectories to the filePaths list.- Parameters:
directory- the current directory being processedfilePaths- the list to store the file paths found
-
searchFiles
Recursively searches for the specified directory within the given directory and its subdirectories. When the directory is found, adds the file paths of all files within that directory to the filePaths list.- Parameters:
directory- the current directory being searcheddirectoryName- the name of the directory to search forfilePaths- the list to store the file paths found
-
hasFiles
Checks if the specified directory contains any files.- Parameters:
directory- The directory path.- Returns:
trueif the directory contains files,falseotherwise.- Throws:
IOException- If an I/O error occurs while accessing the directory.
-
moveMapFileToErrorDirectory
Moves a map file from the overall actual directory (or other place) to an error directory based on its exit code. See also method getMapFilePath in FileHandler class.- Parameters:
mapFilePath- The path of the map file to move.exitCode- The exit code associated with the map file.
-
cleanDirectory
Cleans the specified directory by deleting its files and subdirectories recursively.- Parameters:
pathToNeededCleanedDirectory- The path to the directory that needs to be cleaned.
-