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

public Class FileFilterUtils

extends Object
Class Inheritance
Imports
java.io.File, .FileFilter, .FilenameFilter, java.util.Date

Useful utilities for working with file filters. It provides access to all file filter implementations in this package so you don't have to import every class you use.
Authors
Stephen Colebourne, Jeremias Maerki, Masato Tezuka, Rahul Akolkar
Since
Commons IO 1.0
Version
$Id: FileFilterUtils.java 471628 2006-11-06 04:06:45Z bayard $

Field Summary

Modifier and TypeField and Description
private static IOFileFilter
private static IOFileFilter

Constructor Summary

AccessConstructor and Description
public
FileFilterUtils()

FileFilterUtils is not normally instantiated.

Method Summary

Modifier and TypeMethod and Description
public static IOFileFilter

Returns:

an appropriately configured age file filter
ageFileFilter
(long
the time threshold
cutoff
)

Returns a filter that returns true if the file was last modified after the specified cutoff time.

public static IOFileFilter

Returns:

an appropriately configured age file filter
ageFileFilter
(long
the time threshold
cutoff
,
boolean
if true, older files get accepted, if false, newer
acceptOlder
)

Returns a filter that filters files based on a cutoff time.

public static IOFileFilter

Returns:

an appropriately configured age file filter
ageFileFilter
(Date
the time threshold
cutoffDate
)

Returns a filter that returns true if the file was last modified after the specified cutoff date.

public static IOFileFilter

Returns:

an appropriately configured age file filter
ageFileFilter
(Date
the time threshold
cutoffDate
,
boolean
if true, older files get accepted, if false, newer
acceptOlder
)

Returns a filter that filters files based on a cutoff date.

public static IOFileFilter

Returns:

an appropriately configured age file filter
ageFileFilter
(File
the file whose last modification time is usesd as the threshold age of the files
cutoffReference
)

Returns a filter that returns true if the file was last modified after the specified reference file.

public static IOFileFilter

Returns:

an appropriately configured age file filter
ageFileFilter
(File
the file whose last modification time is usesd as the threshold age of the files
cutoffReference
,
boolean
if true, older files get accepted, if false, newer
acceptOlder
)

Returns a filter that filters files based on a cutoff reference file.

public static IOFileFilter

Returns:

a filter that ANDs the two specified filters
andFileFilter
(IOFileFilter
the first filter
filter1
,
IOFileFilter
the second filter
filter2
)

Returns a filter that ANDs the two specified filters.

public static IOFileFilter

Returns:

a new filter that implements IOFileFilter
asFileFilter
(FileFilter
the filter to be wrapped
filter
)

Returns an IOFileFilter that wraps the FileFilter instance.

public static IOFileFilter

Returns:

a new filter that implements IOFileFilter
asFileFilter
(FilenameFilter
the filter to be wrapped
filter
)

Returns an IOFileFilter that wraps the FilenameFilter instance.

public static IOFileFilter

Returns:

file filter that accepts only directories and not files
directoryFileFilter
()

Returns a filter that checks if the file is a directory.

public static IOFileFilter

Returns:

a false filter
falseFileFilter
()

Returns a filter that always returns false.

public static IOFileFilter

Returns:

file filter that accepts only files and not directories
fileFileFilter
()

Returns a filter that checks if the file is a file (and not a directory).

public static IOFileFilter

Returns:

the decorated filter, never null
makeCVSAware
(IOFileFilter
the filter to decorate, null means an unrestricted filter
filter
)

Decorates a filter to make it ignore CVS directories.

public static IOFileFilter

Returns:

the decorated filter, never null
makeDirectoryOnly
(IOFileFilter
the filter to decorate, null means an unrestricted filter
filter
)

Decorates a filter so that it only applies to directories and not to files.

public static IOFileFilter

Returns:

the decorated filter, never null
makeFileOnly
(IOFileFilter
the filter to decorate, null means an unrestricted filter
filter
)

Decorates a filter so that it only applies to files and not to directories.

public static IOFileFilter

Returns:

the decorated filter, never null
makeSVNAware
(IOFileFilter
the filter to decorate, null means an unrestricted filter
filter
)

Decorates a filter to make it ignore SVN directories.

public static IOFileFilter

Returns:

a name checking filter
nameFileFilter
(String
the filename
name
)

Returns a filter that returns true if the filename matches the specified text.

public static IOFileFilter

Returns:

a filter that NOTs the specified filter
notFileFilter
(IOFileFilter
the filter to invert
filter
)

Returns a filter that NOTs the specified filter.

public static IOFileFilter

Returns:

a filter that ORs the two specified filters
orFileFilter
(IOFileFilter
the first filter
filter1
,
IOFileFilter
the second filter
filter2
)

Returns a filter that ORs the two specified filters.

public static IOFileFilter

Returns:

a prefix checking filter
prefixFileFilter
(String
the filename prefix
prefix
)

Returns a filter that returns true if the filename starts with the specified text.

public static IOFileFilter

Returns:

an appropriately configured SizeFileFilter
sizeFileFilter
(long
the file size threshold
threshold
)

Returns a filter that returns true if the file is bigger than a certain size.

public static IOFileFilter

Returns:

an appropriately configured SizeFileFilter
sizeFileFilter
(long
the file size threshold
threshold
,
boolean
if true, larger files get accepted, if false, smaller
acceptLarger
)

Returns a filter that filters based on file size.

public static IOFileFilter

Returns:

an appropriately configured IOFileFilter
sizeRangeFileFilter
(long
the minimum file size (inclusive)
minSizeInclusive
,
long
the maximum file size (inclusive)
maxSizeInclusive
)

Returns a filter that accepts files whose size is >= minimum size and <= maximum size.

public static IOFileFilter

Returns:

a suffix checking filter
suffixFileFilter
(String
the filename suffix
suffix
)

Returns a filter that returns true if the filename ends with the specified text.

public static IOFileFilter

Returns:

a true filter
trueFileFilter
()

Returns a filter that always returns true.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cvsFilterback to summary
private static IOFileFilter cvsFilter
svnFilterback to summary
private static IOFileFilter svnFilter

Constructor Detail

FileFilterUtilsback to summary
public FileFilterUtils()

FileFilterUtils is not normally instantiated.

Method Detail

ageFileFilterback to summary
public static IOFileFilter ageFileFilter(long cutoff)

Returns a filter that returns true if the file was last modified after the specified cutoff time.

Parameters
cutoff:long

the time threshold

Returns:IOFileFilter

an appropriately configured age file filter

Since
Commons IO 1.2
ageFileFilterback to summary
public static IOFileFilter ageFileFilter(long cutoff, boolean acceptOlder)

Returns a filter that filters files based on a cutoff time.

Parameters
cutoff:long

the time threshold

acceptOlder:boolean

if true, older files get accepted, if false, newer

Returns:IOFileFilter

an appropriately configured age file filter

Since
Commons IO 1.2
ageFileFilterback to summary
public static IOFileFilter ageFileFilter(Date cutoffDate)

Returns a filter that returns true if the file was last modified after the specified cutoff date.

Parameters
cutoffDate:Date

the time threshold

Returns:IOFileFilter

an appropriately configured age file filter

Since
Commons IO 1.2
ageFileFilterback to summary
public static IOFileFilter ageFileFilter(Date cutoffDate, boolean acceptOlder)

Returns a filter that filters files based on a cutoff date.

Parameters
cutoffDate:Date

the time threshold

acceptOlder:boolean

if true, older files get accepted, if false, newer

Returns:IOFileFilter

an appropriately configured age file filter

Since
Commons IO 1.2
ageFileFilterback to summary
public static IOFileFilter ageFileFilter(File cutoffReference)

Returns a filter that returns true if the file was last modified after the specified reference file.

Parameters
cutoffReference:File

the file whose last modification time is usesd as the threshold age of the files

Returns:IOFileFilter

an appropriately configured age file filter

Since
Commons IO 1.2
ageFileFilterback to summary
public static IOFileFilter ageFileFilter(File cutoffReference, boolean acceptOlder)

Returns a filter that filters files based on a cutoff reference file.

Parameters
cutoffReference:File

the file whose last modification time is usesd as the threshold age of the files

acceptOlder:boolean

if true, older files get accepted, if false, newer

Returns:IOFileFilter

an appropriately configured age file filter

Since
Commons IO 1.2
andFileFilterback to summary
public static IOFileFilter andFileFilter(IOFileFilter filter1, IOFileFilter filter2)

Returns a filter that ANDs the two specified filters.

Parameters
filter1:IOFileFilter

the first filter

filter2:IOFileFilter

the second filter

Returns:IOFileFilter

a filter that ANDs the two specified filters

asFileFilterback to summary
public static IOFileFilter asFileFilter(FileFilter filter)

Returns an IOFileFilter that wraps the FileFilter instance.

Parameters
filter:FileFilter

the filter to be wrapped

Returns:IOFileFilter

a new filter that implements IOFileFilter

asFileFilterback to summary
public static IOFileFilter asFileFilter(FilenameFilter filter)

Returns an IOFileFilter that wraps the FilenameFilter instance.

Parameters
filter:FilenameFilter

the filter to be wrapped

Returns:IOFileFilter

a new filter that implements IOFileFilter

directoryFileFilterback to summary
public static IOFileFilter directoryFileFilter()

Returns a filter that checks if the file is a directory.

Returns:IOFileFilter

file filter that accepts only directories and not files

falseFileFilterback to summary
public static IOFileFilter falseFileFilter()

Returns a filter that always returns false.

Returns:IOFileFilter

a false filter

fileFileFilterback to summary
public static IOFileFilter fileFileFilter()

Returns a filter that checks if the file is a file (and not a directory).

Returns:IOFileFilter

file filter that accepts only files and not directories

makeCVSAwareback to summary
public static IOFileFilter makeCVSAware(IOFileFilter filter)

Decorates a filter to make it ignore CVS directories. Passing in null will return a filter that accepts everything except CVS directories.

Parameters
filter:IOFileFilter

the filter to decorate, null means an unrestricted filter

Returns:IOFileFilter

the decorated filter, never null

Since
1.1 (method existed but had bug in 1.0)
makeDirectoryOnlyback to summary
public static IOFileFilter makeDirectoryOnly(IOFileFilter filter)

Decorates a filter so that it only applies to directories and not to files.

Parameters
filter:IOFileFilter

the filter to decorate, null means an unrestricted filter

Returns:IOFileFilter

the decorated filter, never null

Since
1.3
makeFileOnlyback to summary
public static IOFileFilter makeFileOnly(IOFileFilter filter)

Decorates a filter so that it only applies to files and not to directories.

Parameters
filter:IOFileFilter

the filter to decorate, null means an unrestricted filter

Returns:IOFileFilter

the decorated filter, never null

Since
1.3
makeSVNAwareback to summary
public static IOFileFilter makeSVNAware(IOFileFilter filter)

Decorates a filter to make it ignore SVN directories. Passing in null will return a filter that accepts everything except SVN directories.

Parameters
filter:IOFileFilter

the filter to decorate, null means an unrestricted filter

Returns:IOFileFilter

the decorated filter, never null

Since
1.1
nameFileFilterback to summary
public static IOFileFilter nameFileFilter(String name)

Returns a filter that returns true if the filename matches the specified text.

Parameters
name:String

the filename

Returns:IOFileFilter

a name checking filter

notFileFilterback to summary
public static IOFileFilter notFileFilter(IOFileFilter filter)

Returns a filter that NOTs the specified filter.

Parameters
filter:IOFileFilter

the filter to invert

Returns:IOFileFilter

a filter that NOTs the specified filter

orFileFilterback to summary
public static IOFileFilter orFileFilter(IOFileFilter filter1, IOFileFilter filter2)

Returns a filter that ORs the two specified filters.

Parameters
filter1:IOFileFilter

the first filter

filter2:IOFileFilter

the second filter

Returns:IOFileFilter

a filter that ORs the two specified filters

prefixFileFilterback to summary
public static IOFileFilter prefixFileFilter(String prefix)

Returns a filter that returns true if the filename starts with the specified text.

Parameters
prefix:String

the filename prefix

Returns:IOFileFilter

a prefix checking filter

sizeFileFilterback to summary
public static IOFileFilter sizeFileFilter(long threshold)

Returns a filter that returns true if the file is bigger than a certain size.

Parameters
threshold:long

the file size threshold

Returns:IOFileFilter

an appropriately configured SizeFileFilter

Since
Commons IO 1.2
sizeFileFilterback to summary
public static IOFileFilter sizeFileFilter(long threshold, boolean acceptLarger)

Returns a filter that filters based on file size.

Parameters
threshold:long

the file size threshold

acceptLarger:boolean

if true, larger files get accepted, if false, smaller

Returns:IOFileFilter

an appropriately configured SizeFileFilter

Since
Commons IO 1.2
sizeRangeFileFilterback to summary
public static IOFileFilter sizeRangeFileFilter(long minSizeInclusive, long maxSizeInclusive)

Returns a filter that accepts files whose size is >= minimum size and <= maximum size.

Parameters
minSizeInclusive:long

the minimum file size (inclusive)

maxSizeInclusive:long

the maximum file size (inclusive)

Returns:IOFileFilter

an appropriately configured IOFileFilter

Since
Commons IO 1.3
suffixFileFilterback to summary
public static IOFileFilter suffixFileFilter(String suffix)

Returns a filter that returns true if the filename ends with the specified text.

Parameters
suffix:String

the filename suffix

Returns:IOFileFilter

a suffix checking filter

trueFileFilterback to summary
public static IOFileFilter trueFileFilter()

Returns a filter that always returns true.

Returns:IOFileFilter

a true filter