You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2008/09/02 16:32:26 UTC

svn commit: r691264 - /incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java

Author: ritchiem
Date: Tue Sep  2 07:32:25 2008
New Revision: 691264

URL: http://svn.apache.org/viewvc?rev=691264&view=rev
Log:
QPID-1268 : Added single delete and recursive delete method to common FileUtils.

Modified:
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java?rev=691264&r1=691263&r2=691264&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java Tue Sep  2 07:32:25 2008
@@ -192,4 +192,35 @@
             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();
+     }
+    
 }