public static void deleteRecursively ( Path path ) throws IOException { if ( Files . isDirectory ( path ) ) { Files . list ( path ) . forEach ( file -> { try { deleteRecursively ( file ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e . getMessage ( ) , e ) ; } } ) ; } Files . delete ( path ) ; }
Delete the file or directory recursively .