Search in sources :

Example 1 with FileDeletionException

use of com.trivago.rta.exceptions.filesystem.FileDeletionException in project cucable-plugin by trivago.

the class FileSystemManager method removeFilesFromPath.

/**
 * Removes files with the specified extension from the given path.
 *
 * @param path          The path to clear.
 * @param fileExtension The file extension to consider.
 */
private void removeFilesFromPath(final String path, final String fileExtension) throws FileDeletionException {
    File basePath = new File(path);
    File[] files = basePath.listFiles();
    if (files != null) {
        for (File file : files) {
            if (file.getName().endsWith("." + fileExtension) && !file.delete()) {
                throw new FileDeletionException(file.getName());
            }
        }
    }
}
Also used : FileDeletionException(com.trivago.rta.exceptions.filesystem.FileDeletionException) File(java.io.File)

Aggregations

FileDeletionException (com.trivago.rta.exceptions.filesystem.FileDeletionException)1 File (java.io.File)1