summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ritchie <ritchiem@apache.org>2008-09-02 14:32:25 +0000
committerMartin Ritchie <ritchiem@apache.org>2008-09-02 14:32:25 +0000
commita01e82da9c25999ee7f3421bac9d2c13a5c0f696 (patch)
treead6feb64b11bc2529ae6c916325fd2fafeaf1e97
parent4861d93f7ae5c084603fcd0fccc73054620a7093 (diff)
downloadqpid-python-a01e82da9c25999ee7f3421bac9d2c13a5c0f696.tar.gz
QPID-1268 : Added single delete and recursive delete method to common FileUtils.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@691264 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
index 7494745457..814d6e73c9 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
@@ -192,4 +192,35 @@ public class FileUtils
throw new RuntimeException(e);
}
}
+
+ /*
+ * Deletes a given file
+ */
+ public static void deleteFile(String filePath) throws IOException
+ {
+ delete(new File(filePath), false);
+ }
+
+ /**
+ * Delete a given file, if a directory is specified and recursive set then delete the whole tree
+ * @param filePath the File object to start at
+ * @param recursive boolean to recurse if a directory is specified.
+ * @throws IOException
+ */
+ public static void delete(File filePath, boolean recursive) throws IOException
+ {
+ if (filePath.isDirectory())
+ {
+ if (recursive)
+ {
+ for (File subFile : filePath.listFiles())
+ {
+ delete(subFile, true);
+ }
+ }
+ }
+
+ filePath.delete();
+ }
+
}