All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.crabshue.commons.file.nio.FileVisitors Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.crabshue.commons.file.nio;

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * Collection of {@link FileVisitor} to re-use.
 *
 */
public class FileVisitors {


    public static FileVisitor visitAllFiles() {
        return new FileVisitor() {
            @Override
            public FileVisitResult preVisitDirectory(final Object dir, final BasicFileAttributes attrs) throws IOException {
                return FileVisitResult.CONTINUE;
            }

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy