public static void deleteAllFiles ( final File file ) throws IOException { String error = null ; if ( ! file . exists ( ) ) { return ; } final Exception ex = checkFile ( file ) ; if ( ex != null ) { try { throw ex ; } catch ( final Exception e ) { e . printStackTrace ( ) ; } } DeleteFileExtensions . deleteFiles ( file ) ; if ( ! file . delete ( ) ) { error = "Cannot delete the File " + file . getAbsolutePath ( ) + "." ; throw new IOException ( error ) ; } }
Deletes the File and if it is an directory it deletes his sub - directories recursively .