Java Reference
In-Depth Information
}
}
WhenI,forexample,specify java Dir c:\windows bmp onmyXPplatform,
Dir outputsonlythose \windows directoryfilenamesthathavethe bmp (bitmap)ex-
tension:
Blue Lace 16.bmp
Coffee Bean.bmp
FeatherTexture.bmp
Gone Fishing.bmp
Greenstone.bmp
Prairie Wind.bmp
Rhododendron.bmp
River Sumida.bmp
Santa Fe Stucco.bmp
Soap Bubbles.bmp
winnt.bmp
winnt256.bmp
Zapotec.bmp
The overloaded listFiles() methods return arrays of File s. For the most
part, they're symmetrical with their list() counterparts. However,
listFiles(FileFilter) introduces an asymmetry.
The java.io.FileFilter interface declares a single boolean ac-
cept(String pathname) method that's called for each file/directory located in
the directory identified by the File object's abstract pathname. The argument passed
to pathname identifies the complete path of the file or directory.
The accept() method uses this argument to determine whether or not the file or
directorysatisfiesitscriteriaforwhatisacceptable.Itreturnstruewhenthefile/direct-
ory name should be included in the returned array; otherwise, this method returns false.
Tip Becauseeachinterface's accept() methodaccomplishesthesametask,you
mightbewonderingwhichinterfacetouse.Ifyoupreferapathbrokenintoitsdirectory
and name components, use FilenameFilter . However, if you prefer a complete
pathname,use FileFilter ;youcanalwayscall getParent() and getName()
to get these components.
Search WWH ::




Custom Search