com.crabshue.commons.file.nio.FileVisitors Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-nio-file Show documentation
Show all versions of commons-nio-file Show documentation
Library for file system operations (using java.nio.file).
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;
}
};
}
}