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:Search.java

@Override
public FileVisitResult visitFile(Object file, BasicFileAttributes attrs) throws IOException {
    search((Path) file);/*from ww  w .  java2  s. c om*/
    if (!found) {
        return FileVisitResult.CONTINUE;
    } else {
        return FileVisitResult.TERMINATE;
    }
}

From source file:de.bbe_consulting.mavento.helper.visitor.FileSizeVisitor.java

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

    if (attrs.isRegularFile()) {
        sizeTotal.add(attrs.size());/* w  w  w  .  ja va2 s.  c om*/
    }
    return FileVisitResult.CONTINUE;
}

From source file:org.talend.dataprep.cache.file.FileSystemVisitor.java

@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
    final String fileName = file.toFile().getName();
    // Ignore "." files (hidden files like MacOS).
    if (fileName.startsWith(".")) {
        return FileVisitResult.CONTINUE;
    }/*from w  w w. ja  v  a  2s.  c  om*/
    final String suffix = StringUtils.substringAfterLast(fileName, ".");
    // Ignore NFS files (may happen in local mode when NFS is used).
    if (suffix.startsWith("nfs")) {
        return FileVisitResult.CONTINUE;
    }
    if (this.skipPermanent && StringUtils.isEmpty(suffix)) {
        return FileVisitResult.CONTINUE;
    }
    consumer.accept(file, suffix);
    return super.visitFile(file, attrs);
}

From source file:org.sonarsource.commandlinezip.ZipUtils7.java

public static void zipDir(final Path srcDir, Path zip) throws IOException {

    try (final OutputStream out = FileUtils.openOutputStream(zip.toFile());
            final ZipOutputStream zout = new ZipOutputStream(out)) {
        Files.walkFileTree(srcDir, new SimpleFileVisitor<Path>() {
            @Override// w ww  .j  a  va 2 s .c  o  m
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                try (InputStream in = new BufferedInputStream(new FileInputStream(file.toFile()))) {
                    String entryName = srcDir.relativize(file).toString();
                    ZipEntry entry = new ZipEntry(entryName);
                    zout.putNextEntry(entry);
                    IOUtils.copy(in, zout);
                    zout.closeEntry();
                }
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                if (dir.equals(srcDir)) {
                    return FileVisitResult.CONTINUE;
                }

                String entryName = srcDir.relativize(dir).toString();
                ZipEntry entry = new ZipEntry(entryName);
                zout.putNextEntry(entry);
                zout.closeEntry();
                return FileVisitResult.CONTINUE;
            }
        });
    }
}

From source file:Search.java

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

From source file:jobs.ExportDatabaseToFilesystem.java

public void doJob() throws Exception {
    Path p = PathService.getRootImageDirectory();
    Files.walkFileTree(p, new SimpleFileVisitor<Path>() {
        @Override/* w  w w .  j  a  v a2s. c o  m*/
        public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
            if (PathService.isImage(path)) {
                DatabaseImage dbi = DatabaseImage.forPath(path);
                ImportExportService.exportData(dbi);
            }
            return FileVisitResult.CONTINUE;
        }
    });
}

From source file:org.apdplat.superword.extract.PhraseExtractor.java

public static Set<String> parseDir(String dir) {
    Set<String> data = new HashSet<>();
    LOGGER.info("?" + dir);
    try {//from  www  .  j  av a 2s.c om
        Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() {

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

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

From source file:org.apdplat.superword.extract.DefinitionExtractor.java

public static Set<Word> parseDir(String dir) {
    Set<Word> data = new HashSet<>();
    LOGGER.info("?" + dir);
    try {//  w  w  w  .j a v a  2s. co  m
        Files.walkFileTree(Paths.get(dir), new SimpleFileVisitor<Path>() {

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

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

From source file:Test.java

@Override
public FileVisitResult preVisitDirectory(Path directory, BasicFileAttributes attributes) throws IOException {
    Path targetDirectory = target.resolve(source.relativize(directory));
    try {/*from ww  w.  j a  va2  s .  c o m*/
        System.out.println("Copying " + source.relativize(directory));
        Files.copy(directory, targetDirectory);
    } catch (FileAlreadyExistsException e) {
        if (!Files.isDirectory(targetDirectory)) {
            throw e;
        }
    }
    return FileVisitResult.CONTINUE;
}

From source file:com.ejisto.util.visitor.ConditionMatchingCopyFileVisitor.java

@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
    if (options.srcRoot.compareTo(dir) < 0
            && options.copyType == CopyType.INCLUDE_ONLY_ROOT_MATCHING_RESOURCES) {
        return FileVisitResult.SKIP_SUBTREE;
    }// w  w  w  . j a  va2s . c om
    Path dest = options.targetRoot.resolve(options.srcRoot.relativize(dir));
    if (!Files.exists(dest)) {
        Files.createDirectories(dest);
    }
    return FileVisitResult.CONTINUE;
}