Java Utililty Methods Path Remove nio

List of utility methods to do Path Remove nio

Description

The list of methods to do Path Remove nio are organized into topic(s).

Method

booleanremoveLine(String path, String line, boolean commentAware)
Removes this line from the specified file.
boolean hasLine = fileHasLine(path, line, commentAware);
if (hasLine) {
    String[] lines = getLines(path, true);
    if (hasLine) {
        String text = "";
        for (int i = 0; i < lines.length; i++) {
            if (!lines[i].matches(line + (commentAware ? "(\\s*//.*)?" : ""))) {
                text += lines[i] + System.lineSeparator();
...
voidremoveRecursive(Path path)
Delete directory recursively.
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
    @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 {
...
voidremoveRecursive(Path path)
remove Recursive
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
    @Override
    public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
        if (exc == null) {
            Files.delete(dir);
            return FileVisitResult.CONTINUE;
        } else {
            throw exc;
...
voidremoveSymlink(Path softLinkLocation)
remove Symlink
try {
    BasicFileAttributes basicFileAttributes = getBasicFileAttributes(softLinkLocation);
    if (!basicFileAttributes.isSymbolicLink()) {
        throw new IOException("tried to delete a symlink which wasn't a symlink.");
    Files.delete(softLinkLocation);
} catch (IOException e) {
    System.err.println(e);
...
voidreportRemoveSymink(Path softLinkLocation)
report Remove Symink
reportRemoveSymink(softLinkLocation.toString());
LinkedHashMaprm(final LinkedHashMap unremoved, Path... locations)
rm
if (locations != null) {
    for (Path location : locations) {
        if (location != null && Files.exists(location)) {
            try {
                Files.walkFileTree(location, new FileVisitor<Path>() {
                    @Override
                    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                            throws IOException {
...