FileDocCategorySizeDatePackage
DirList2.javaAPI DocExample3208Mon Apr 06 18:10:22 BST 1998None

DirList2

public class DirList2 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static java.io.FilenameFilterfilter(java.lang.String afn)

    // Creation of anonymous inner class:
    return new FilenameFilter() {
      String fn = afn;
      public boolean accept(File dir, String n) {
        // Strip path information:
        String f = new File(n).getName();
        return f.indexOf(fn) != -1;
      }
    }; // End of anonymous inner class
  
public static voidmain(java.lang.String[] args)

    try {
      File path = new File(".");
      String[] list;
      if(args.length == 0)
        list = path.list();
      else 
        list = path.list(filter(args[0]));
      for(int i = 0; i < list.length; i++)
        System.out.println(list[i]);
    } catch(Exception e) {
      e.printStackTrace();
    }