From 798740f88ffa2faa22733ca3c05a1fb29be7eea6 Mon Sep 17 00:00:00 2001 From: dblouin <dominique.blouin@telecom-paristech.fr> Date: Tue, 21 Nov 2017 11:23:55 +0100 Subject: [PATCH] Allow file extension to be null to delete all directory content --- src/main/java/myutil/FileUtils.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/myutil/FileUtils.java b/src/main/java/myutil/FileUtils.java index c50661b6e8..5a120b797c 100755 --- a/src/main/java/myutil/FileUtils.java +++ b/src/main/java/myutil/FileUtils.java @@ -417,12 +417,23 @@ public class FileUtils extends org.apache.commons.io.FileUtils{ } } + public static String deleteFiles( String d ) { + return deleteFiles( d, null ); + } + // d: directory, e : extension public static String deleteFiles(String d, String e ) { - ExtensionFilter filter = new ExtensionFilter(e); File dir = new File(d); + final String[] list; + + if ( e == null ) { + list = dir.list(); + } + else { + final ExtensionFilter filter = new ExtensionFilter(e); + list = dir.list(filter); + } - String[] list = dir.list(filter); File file; boolean isDeleted; -- GitLab