Top Description Fields Constructors Methods
org.apache.commons.io.filefilter

public Class CanReadFileFilter

extends AbstractFileFilter
Class Inheritance
Imports
java.io.File

This filter accepts Files that can be read.

Example, showing how to print out a list of the current directory's readable files:

File dir = new File(".");
String[] files = dir.list( 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:

File dir = new File(".");
String[] files = dir.list( 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:

File dir = new File(".");
String[] files = dir.list( CanReadFileFilter.READ_ONLY );
for ( int i = 0; i < files.length; i++ ) {
    System.out.println(files[i]);
}
Since
Commons IO 1.3
Version
$Revision: 437567 $

Field Summary

Modifier and TypeField and Description
public static final IOFileFilter
CAN_READ

Singleton instance of readable filter

public static final IOFileFilter
CANNOT_READ

Singleton instance of not readable filter

public static final IOFileFilter
READ_ONLY

Singleton instance of read-only filter

Constructor Summary

AccessConstructor and Description
protected
CanReadFileFilter()

Restrictive consructor.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the file can be read, otherwise false.
accept
(File
the File to check.
file
)

Overrides org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Implements org.apache.commons.io.filefilter.IOFileFilter.accept.

Checks to see if the file can be read.
Inherited from org.apache.commons.io.filefilter.AbstractFileFilter:
accept

Field Detail

CAN_READback to summary
public static final IOFileFilter CAN_READ

Singleton instance of readable filter

CANNOT_READback to summary
public static final IOFileFilter CANNOT_READ

Singleton instance of not readable filter

READ_ONLYback to summary
public static final IOFileFilter READ_ONLY

Singleton instance of read-only filter

Constructor Detail

CanReadFileFilterback to summary
protected CanReadFileFilter()

Restrictive consructor.

Method Detail

acceptback to summary
public boolean accept(File file)

Overrides org.apache.commons.io.filefilter.AbstractFileFilter.accept.

Implements org.apache.commons.io.filefilter.IOFileFilter.accept.

Checks to see if the file can be read.

Parameters
file:File

the File to check.

Returns:boolean

true if the file can be read, otherwise false.