private boolean deleteBundleCacheDir ( File path ) { final boolean trace = TraceComponent . isAnyTracingEnabled ( ) ; if ( FileUtils . fileExists ( path ) ) { if ( trace && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "Path specified exists: " + path . getPath ( ) ) ; } } else { if ( trace && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "Path specified does not exist: " + path . getPath ( ) ) ; } return true ; } boolean deleteWorked = true ; for ( File file : FileUtils . listFiles ( path ) ) { if ( FileUtils . fileIsDirectory ( file ) ) { if ( trace && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "Delete directory contents: " + file . toString ( ) ) ; } deleteWorked &= deleteBundleCacheDir ( file ) ; } else { if ( trace && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "Delete file: " + file . toString ( ) ) ; } if ( ! FileUtils . fileDelete ( file ) ) { deleteWorked = false ; if ( trace && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "Directory or file not deleted" ) ; } } } } if ( trace && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "Delete path: " + path ) ; } if ( ! FileUtils . fileDelete ( path ) ) { deleteWorked = false ; if ( trace && tc . isDebugEnabled ( ) ) { Tr . debug ( this , tc , "Path not deleted" ) ; } } return deleteWorked ; }
Deletes the directory and its contents or the file that is specified