public class HiddenFileFilter extends AbstractFileFilter implements java.io.Serializable
File
s that are hidden.
Example, showing how to print out a list of the current directory's hidden files:
File dir = FileUtils.current(); String[] files = dir.list(HiddenFileFilter.HIDDEN); for (String file : files) { System.out.println(file); }
Example, showing how to print out a list of the current directory's visible (i.e. not hidden) files:
File dir = FileUtils.current(); String[] files = dir.list(HiddenFileFilter.VISIBLE); for (String file : files) { System.out.println(file); }
final Path dir = PathUtils.current(); final AccumulatorPathVisitor visitor = AccumulatorPathVisitor.withLongCounters(HiddenFileFilter.HIDDEN); // // Walk one dir Files.walkFileTree(dir, Collections.emptySet(), 1, visitor); System.out.println(visitor.getPathCounters()); System.out.println(visitor.getFileList()); // visitor.getPathCounters().reset(); // // Walk dir tree Files.walkFileTree(dir, visitor); System.out.println(visitor.getPathCounters()); System.out.println(visitor.getDirList()); System.out.println(visitor.getFileList());
Serialization is deprecated and will be removed in 3.0.
Modifier and Type | Field and Description |
---|---|
static IOFileFilter |
HIDDEN
Singleton instance of hidden filter
|
private static long |
serialVersionUID |
static IOFileFilter |
VISIBLE
Singleton instance of visible filter
|
EMPTY_STRING_ARRAY
Modifier | Constructor and Description |
---|---|
protected |
HiddenFileFilter()
Restrictive constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File file)
Checks to see if the file is hidden.
|
java.nio.file.FileVisitResult |
accept(java.nio.file.Path file,
java.nio.file.attribute.BasicFileAttributes attributes)
Checks to see if the file is hidden.
|
accept, append, append, get, handle, postVisitDirectory, preVisitDirectory, toDefaultFileVisitResult, toFileVisitResult, toString, visitFile, visitFileFailed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
and, matches, negate, or
public static final IOFileFilter HIDDEN
private static final long serialVersionUID
public static final IOFileFilter VISIBLE
public boolean accept(java.io.File file)
accept
in interface java.io.FileFilter
accept
in interface IOFileFilter
accept
in class AbstractFileFilter
file
- the File to checktrue
if the file is
hidden, otherwise false
.public java.nio.file.FileVisitResult accept(java.nio.file.Path file, java.nio.file.attribute.BasicFileAttributes attributes)
accept
in interface PathFilter
accept
in interface IOFileFilter
file
- the File to checkattributes
- the file's basic attributes (TODO may be null).true
if the file is
hidden, otherwise false
.