@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; }
@Override public void delete(final Path path, final DeleteOption... options) throws IllegalArgumentException, NoSuchFileException, DirectoryNotEmptyException, IOException, SecurityException { Files.delete(path, options); try { Files.deleteIfExists(dot(path), options); } catch (Exception ex) { } if (path instanceof AttrHolder) { ((AttrHolder) path).getAttrStorage().clear(); } }
@Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } });
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } });
@Override public void delete(final Path path, final DeleteOption... options) throws IllegalArgumentException, NoSuchFileException, DirectoryNotEmptyException, IOException, SecurityException { Files.delete(path, options); }
@After public void clearDown() { for (final Path p : pathsToDelete) { Files.delete(p); } }
@Test public void deleteNull() { assertThatThrownBy(() -> Files.delete(null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Parameter named 'path' should be not null!"); }
@Test public void deleteNoSuchFileException() { assertThatThrownBy(() -> Files.delete(newTempDir().resolve("file.temp.txt"))) .isInstanceOf(NoSuchFileException.class); }
Files.write(item.getPath(), item.getContent()); } else { Files.delete(item.getPath());
@Test public void deleteDirectoryNotEmpty() { final Path dir = newTempDir(); Files.createFile(dir.resolve("file.temp.txt")); assertThatThrownBy(() -> Files.delete(dir)) .isInstanceOf(DirectoryNotEmptyException.class); }
append("/"). append(POM_NAME).toString())); Files.delete(pomParent); Files.write(pomParent, baos.toByteArray(),
@Override public Path move(final Path source, final Path target, final CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, AtomicMoveNotSupportedException, IOException, SecurityException { if (Files.exists(dot(source))) { Files.move(dot(source), dot(target), forceBuildOptions(options)); } else if (Files.exists(dot(target))) { Files.delete(dot(target)); } final Path result = Files.move(source, target, options); return result; }
@Override public Path copy(final Path source, final Path target, final CopyOption... options) throws UnsupportedOperationException, FileAlreadyExistsException, DirectoryNotEmptyException, IOException, SecurityException { if (Files.exists(dot(source))) { Files.copy(dot(source), dot(target), forceBuildOptions(options)); } else if (Files.exists(dot(target))) { Files.delete(dot(target)); } final Path result = Files.copy(source, target, options); return result; }
@Test public void delete() { final Path path = Files.createFile(newTempDir().resolve("file.temp.txt")); assertThat(path).isNotNull(); assertThat(path.toFile()).exists(); Files.delete(path); assertThat(path).isNotNull(); assertThat(path.toFile()).doesNotExist(); final Path dir = newTempDir(); assertThat(dir).isNotNull(); assertThat(dir.toFile()).exists(); Files.delete(dir); assertThat(dir).isNotNull(); assertThat(dir.toFile()).doesNotExist(); }