File 类的方法:list(FilenameFilter filter)
1020 public String[] list(FilenameFilter filter) {
1021 String names[] = list();
1022 if ((names == null) || (filter == null)) {
1023 return names;
1024 }
1025 ArrayList v = new ArrayList();
1026 for (int i = 0 ; i < names.length ; i++) {
1027 if (filter.accept(this, names[i])) {
1028 v.add(names[i]);
1029 }
1030 }
1031 return (String[])(v.toArray(new String[v.size()]));
1032 }
1033
42 public
43 interface FilenameFilter {
44 /**
45 * Tests if a specified file should be included in a file list.
46 *
47 * @param dir the directory in which the file was found.
48 * @param name the name of the file.
49 * @return <code>true</code> if and only if the name should be
50 * included in the file list; <code>false</code> otherwise.
51 */
52 boolean accept(File dir, String name);
53 }