public static boolean delFileOrFolder ( File file ) { if ( file == null || ! file . exists ( ) ) { // do nothing } else if ( file . isFile ( ) ) { file . delete ( ) ; } else if ( file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( File sonFile : files ) { delFileOrFolder ( sonFile ) ; } } file . delete ( ) ; } return true ; }
Delete file or folder .