question: public static boolean delete ( File file , boolean deleteOnExit ) { if ( file == null ) throw new NullPointerException ( "File cannot be null" ) ; if ( ! file . exists ( ) ) return true ; if ( file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; for ( int i = 0 ; i < files . length ; i ++ ) delete ( files [ i ] , deleteOnExit ) ; } if ( ! file . delete ( ) ) { if ( Utilities . isWindows ( ) && file . isFile ( ) ) { for ( int i = 0 ; i < 5 ; i ++ ) { System . gc ( ) ; if ( file . delete ( ) ) return true ; } } if ( deleteOnExit ) file . deleteOnExit ( ) ; return false ; } return true ; }
target:  Deletes file or folder. Optionally invokes deleteOnExit if necessary.