Advertisement
robin4002

Untitled

Mar 18th, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.  
  2.     public static void recursifDelete(File path) throws IOException
  3.     {
  4.         if(!path.exists())
  5.         {
  6.             throw new IOException("File not found '" + path.getAbsolutePath() + "'");
  7.         }
  8.         if(path.isDirectory())
  9.         {
  10.             File[] children = path.listFiles();
  11.             for(int i = 0; children != null && i < children.length; i++)
  12.                 recursifDelete(children[i]);
  13.             if(!path.delete())
  14.             {
  15.                 throw new IOException("No delete path '" + path.getAbsolutePath() + "'");
  16.             }
  17.         }
  18.         else if(!path.delete())
  19.         {
  20.             throw new IOException("No delete file '" + path.getAbsolutePath() + "'");
  21.         }
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement