FileDocCategorySizeDatePackage
DirectoryLister.javaAPI DocExample829Tue Feb 14 13:40:30 GMT 2006None

DirectoryLister

public class DirectoryLister extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    
    SwingUtilities.invokeAndWait(
      new Runnable() {
        public void run() {
          JFileChooser fc = new JFileChooser();
          fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
          
          int result = fc.showOpenDialog(new JFrame());
          if (result == JFileChooser.APPROVE_OPTION) {
            File dir = fc.getSelectedFile();
            String[] contents = dir.list();
            for (int i = 0; i < contents.length; i++) {
              System.out.println(contents[i]);
            }
          }
          System.exit(0);
        }
      }
    );