public static void deleteRecursively ( final Path path ) throws IOException { DeploymentRepositoryLogger . ROOT_LOGGER . debugf ( "Deleting %s recursively" , path ) ; if ( Files . exists ( path ) ) { Files . walkFileTree ( path , new FileVisitor < Path > ( ) { @ Override public FileVisitResult preVisitDirectory ( Path dir , BasicFileAttributes attrs ) throws IOException { return FileVisitResult . CONTINUE ; } @ Override public FileVisitResult visitFile ( Path file , BasicFileAttributes attrs ) throws IOException { Files . delete ( file ) ; return FileVisitResult . CONTINUE ; } @ Override public FileVisitResult visitFileFailed ( Path file , IOException exc ) throws IOException { DeploymentRepositoryLogger . ROOT_LOGGER . cannotDeleteFile ( exc , path ) ; throw exc ; } @ Override public FileVisitResult postVisitDirectory ( Path dir , IOException exc ) throws IOException { Files . delete ( dir ) ; return FileVisitResult . CONTINUE ; } } ) ; } }
Delete a path recursively .