question: public static void delete ( File fileOrDirectory ) { if ( ! fileOrDirectory . exists ( ) ) { return ; } if ( fileOrDirectory . isDirectory ( ) ) { File [ ] filesList = fileOrDirectory . listFiles ( ) ; for ( File child : filesList ) { delete ( child ) ; } } final File to = new File ( fileOrDirectory . getAbsolutePath ( ) + System . currentTimeMillis ( ) ) ; fileOrDirectory . renameTo ( to ) ; to . delete ( ) ; }
target:  Delete file object. If it is a folder - it will be deleted recursively will all content.