Package org.apache.commons.vfs2.filter
Class CanReadFileFilter
- java.lang.Object
-
- org.apache.commons.vfs2.filter.CanReadFileFilter
-
- All Implemented Interfaces:
java.io.Serializable
,FileFilter
public class CanReadFileFilter extends java.lang.Object implements FileFilter, java.io.Serializable
This filter acceptsFile
s that can be read.Example, showing how to print out a list of the current directory's readable files:
FileSystemManager fsManager = VFS.getManager(); FileObject dir = fsManager.toFileObject(new File(".")); FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.CAN_READ)); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); }
Example, showing how to print out a list of the current directory's un-readable files:
FileSystemManager fsManager = VFS.getManager(); FileObject dir = fsManager.toFileObject(new File(".")); FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.CANNOT_READ)); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); }
Example, showing how to print out a list of the current directory's read-only files:
FileSystemManager fsManager = VFS.getManager(); FileObject dir = fsManager.toFileObject(new File(".")); FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.READ_ONLY)); for (int i = 0; i < files.length; i++) { System.out.println(files[i]); }
- Since:
- 2.4
- Author:
- This code was originally ported from Apache Commons IO File Filter
- See Also:
- "https://commons.apache.org/proper/commons-io/", Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static FileFilter
CAN_READ
Singleton instance of readable filter.static FileFilter
CANNOT_READ
Singleton instance of not readable filter.static FileFilter
READ_ONLY
Singleton instance of read-only filter.
-
Constructor Summary
Constructors Modifier Constructor Description protected
CanReadFileFilter()
Restrictive constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(FileSelectInfo fileSelectInfo)
Checks to see if the file can be read.
-
-
-
Field Detail
-
CAN_READ
public static final FileFilter CAN_READ
Singleton instance of readable filter.
-
CANNOT_READ
public static final FileFilter CANNOT_READ
Singleton instance of not readable filter.
-
READ_ONLY
public static final FileFilter READ_ONLY
Singleton instance of read-only filter.
-
-
Constructor Detail
-
CanReadFileFilter
protected CanReadFileFilter()
Restrictive constructor.
-
-
Method Detail
-
accept
public boolean accept(FileSelectInfo fileSelectInfo) throws FileSystemException
Checks to see if the file can be read.- Specified by:
accept
in interfaceFileFilter
- Parameters:
fileSelectInfo
- the File to check.- Returns:
true
if the file can be read, otherwisefalse
.- Throws:
FileSystemException
- Thrown for file system errors.
-
-