qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r691264 - /incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java
Date Tue, 02 Sep 2008 14:32:26 GMT
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();
+     }
+    
 }



Mime
View raw message