FileDocCategorySizeDatePackage
SortedDirList.javaAPI DocExample3553Mon Apr 06 18:10:22 BST 1998None

SortedDirList

public class SortedDirList extends Object

Fields Summary
private File
path
private String[]
list
Constructors Summary
public SortedDirList(String afn)

    path = new File(".");
    if(afn == null)
      list = path.list();
    else
      list = path.list(
          new FilenameFilter() {
            public boolean 
            accept(File dir, String n) {
              String f = new File(n).getName();
              return f.indexOf(afn) != -1;
            }
          });
    sort();
  
Methods Summary
public static voidmain(java.lang.String[] args)

    SortedDirList sd;
    if(args.length == 0)
      sd = new SortedDirList(null);
    else
      sd = new SortedDirList(args[0]);
    sd.print();
  
voidprint()

    for(int i = 0; i < list.length; i++)
      System.out.println(list[i]);
  
private voidsort()

    StrSortVector sv = new StrSortVector();
    for(int i = 0; i < list.length; i++)
      sv.addElement(list[i]);
    // The first time an element is pulled from
    // the StrSortVector the list is sorted:
    for(int i = 0; i < list.length; i++)
      list[i] = sv.elementAt(i);