com.ccg.io
Class FilenameFilterDir
java.lang.Object
com.ccg.io.FilenameFilterDir
- All Implemented Interfaces:
- FilenameFilter
public class FilenameFilterDir
- extends Object
- implements FilenameFilter
Simple filter to find directory entries.
This file filter can be used to find directory entries under a
specific directory. The easiest way to see how to use this class is
to look at the following example which prints out the directory
entries under the directory specified:
import com.ccg.io.FilenameFilterDir;
import java.io.*;
class Example {
public static void main(String[] args) {
String dirName = ".";
if (args.length == 1) dirName = args[0];
File dir = new File(dirName);
String[] dlist = dir.list(new FilenameFilterDir());
System.out.println(dir+" entries:"+dlist.length);
for (int i = 0; i < dlist.length; i++) {
System.out.println(" "+dlist[i]);
}
}
}
- Since:
- 1.0
- Version:
- $Revision: 1.1 $
- Author:
- $Author: pkb $
- See Also:
FilenameFilter
|
Method Summary |
boolean |
accept(File dir,
String name)
Accept only names which correspond to directory entries. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FilenameFilterDir
public FilenameFilterDir()
accept
public boolean accept(File dir,
String name)
- Accept only names which correspond to directory entries.
This method checks the "name" of the entry under the specified
"dir". If the "name" refers to a directory, this method returns
true, otherwise, it returns false.
- Specified by:
accept in interface FilenameFilter
- Parameters:
dir - Parent directory of entry to check (we handle null)name - Name under the directory to check (we handle null)
- Returns:
- true if parameters passed indicate a directory entry, false if not.
- Since:
- 1.0
Copyright 1998-1998-2006 null. All Rights Reserved.