Example usage for java.nio.file FileVisitResult CONTINUE

List of usage examples for java.nio.file FileVisitResult CONTINUE

Introduction

In this page you can find the example usage for java.nio.file FileVisitResult CONTINUE.

Prototype

FileVisitResult CONTINUE

To view the source code for java.nio.file FileVisitResult CONTINUE.

Click Source Link

Document

Continue.

Usage

From source file:org.structr.web.maintenance.deploy.ComponentImportVisitor.java

@Override
public FileVisitResult visitFileFailed(final Path file, final IOException exc) throws IOException {

    logger.warn("Exception while importing file {}: {}", new Object[] { file.toString(), exc.getMessage() });
    return FileVisitResult.CONTINUE;
}

From source file:it.infn.ct.futuregateway.apiserver.storage.LocalStorage.java

@Override
public final void removeAllFiles(final RESOURCE res, final String id) throws IOException {
    java.nio.file.Path filePath = Paths.get(path, res.name().toLowerCase(), id);
    if (Files.notExists(filePath)) {
        return;//from w  ww.j  av  a2  s .  c  om
    }
    if (Files.isDirectory(filePath)) {
        Files.walkFileTree(filePath, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult postVisitDirectory(final Path dir, final IOException exc)
                    throws IOException {
                Files.delete(dir);
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs)
                    throws IOException {
                Files.delete(file);
                return FileVisitResult.CONTINUE;
            }
        });
    }
    Files.delete(filePath);
}

From source file:org.apdplat.superword.tools.WordClassifier.java

public static void parseDir(String dir) {
    LOGGER.info("?" + dir);
    try {/*ww w.j  a v  a2 s. com*/
        Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                parseFile(file.toFile().getAbsolutePath());
                return FileVisitResult.CONTINUE;
            }

        });
    } catch (IOException e) {
        LOGGER.error("?", e);
    }
}

From source file:ufo.test.spark.service.WordCountServiceTest.java

private void deleteRecursively(Path path) throws IOException {
    if (Files.exists(path)) {
        //delete recursively
        Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
            @Override/*from   w  w  w  .  j  a va2  s .c om*/
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                Files.delete(file);
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                Files.delete(dir);
                return FileVisitResult.CONTINUE;
            }
        });
    }
    assertFalse(Files.exists(path));
}

From source file:org.phenotips.variantstore.input.vcf.VCFManager.java

@Override
public List<String> getAllIndividuals() {
    final List<String> list = new ArrayList<>();

    try {/*from   ww w . j  ava 2s  .co m*/
        Files.walkFileTree(this.path, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                if (attrs.isDirectory()) {
                    return FileVisitResult.CONTINUE;
                }
                String id = file.getFileName().toString();
                id = StringUtils.removeEnd(id, suffix);
                list.add(id);
                return FileVisitResult.CONTINUE;
            }
        });
    } catch (IOException e) {
        logger.error("Error getting all individuals");
    }

    return list;
}

From source file:neembuu.uploader.zip.generator.NUZipFileGenerator.java

private void walkOverAllFiles() throws IOException {
    for (final Path uploadersDirectory : uploadersDirectories) {
        Files.walkFileTree(uploadersDirectory, new FileVisitor<Path>() {
            @Override/* w w w  .j  av a2  s  . co m*/
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                exc.printStackTrace();
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                if (file.getFileName().toString().endsWith(".class")) {
                    visitClassFile(file, attrs, uploadersDirectory);
                }
                return FileVisitResult.CONTINUE;
            }
        });
    }

}

From source file:com.marklogic.hub.RestAssetLoader.java

/**
 * FileVisitor method that determines if we should visit the directory or not via the fileFilter.
 *//*from  www  . j a v a  2s. c o m*/
@Override
public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attributes) throws IOException {
    logger.info("filename: " + path.toFile().getName());
    boolean accept = fileFilter.accept(path.toFile());
    if (accept) {
        if (logger.isDebugEnabled()) {
            logger.debug("Visiting directory: " + path);
        }
        return FileVisitResult.CONTINUE;
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("Skipping directory: " + path);
        }
        return FileVisitResult.SKIP_SUBTREE;
    }
}

From source file:act.installer.pubchem.PubchemTTLMergerTest.java

@After
public void tearDown() throws Exception {
    // Clean up temp dir once the test is complete.  TODO: use mocks instead maybe?  But testing RocksDB helps too...
    /* With help from:/*from  w w  w .j a va2s .c  o m*/
     * http://stackoverflow.com/questions/779519/delete-directories-recursively-in-java/27917071#27917071 */
    Files.walkFileTree(tempDirPath, 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 {
            // walkFileTree may ignore . and .., but I have never found it a /bad/ idea to check for these special names.
            if (!THIS_DIR.equals(file.toFile().getName()) && !PARENT_DIR.equals(file.toFile().getName())) {
                Files.delete(file);
            }
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
            throw exc;
        }

        @Override
        public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
            Files.delete(dir);
            return FileVisitResult.CONTINUE;
        }
    });

    // One last check to make sure the top level directory is removed.
    if (tempDirPath.toFile().exists()) {
        Files.delete(tempDirPath);
    }
}

From source file:org.structr.web.maintenance.deploy.ComponentImportVisitor.java

@Override
public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
    return FileVisitResult.CONTINUE;
}

From source file:org.nuxeo.connect.update.standalone.PackageTestCase.java

/** Zips a directory into the given ZIP file. */
protected void createZip(File zip, Path basePath) throws IOException {
    try (ZipOutputStream zout = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zip)))) {
        Files.walkFileTree(basePath, new SimpleFileVisitor<Path>() {
            @Override/*  w w w  . j  a v a2  s . com*/
            public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
                if (attrs.isDirectory()) {
                    return FileVisitResult.CONTINUE;
                }
                String rel = basePath.relativize(path).toString();
                if (rel.startsWith(".")) {
                    return FileVisitResult.CONTINUE;
                }
                zout.putNextEntry(new ZipEntry(rel));
                try (InputStream in = Files.newInputStream(path)) {
                    org.apache.commons.io.IOUtils.copy(in, zout);
                }
                zout.closeEntry();
                return FileVisitResult.CONTINUE;
            }
        });
        zout.flush();
    }
}