- import java.io.*;
- public class Hello
- {
- public static void main(String [] args)
- {
- try
- {
- File path = new File(".");
- String[] list;
- if(args.length == 0)
- list = path.list();
- else
- list = path.list(new DirFilter(args[0]));
- for(int i = 0; i < list.length; i++)
- {
- System.out.println(list[i]);
- }
-
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- class DirFilter implements FilenameFilter
- {
- String afn;
- DirFilter(String afn)
- {
- this.afn = afn;
- }
- public boolean accept(File dir, String name) //不知道是何时调用了该方法?
- {
- String f = new File(name).getName();
- return f.indexOf(afn) != -1;
- //return true;
- }
- }
复制代码 这个accept方法是什么时候调用的啊?
|
|