    01: import java.io.*;
    02:
    03: public class DirectoryNode implements FileSystemNode
    04: {
    05:    public DirectoryNode(File directory)
    06:    {
    07:       this.directory = directory;
    08:    }
    09:
    10:    public void accept(FileSystemVisitor v)
    11:    {
    12:       v.visitDirectoryNode(this);
    13:    }
    14:
    15:    public File getDirectory() { return directory; }
    16:
    17:    public FileSystemNode[] getChildren()
    18:    {
    19:       File[] files = directory.listFiles();
    20:       FileSystemNode[] children
    21:          = new FileSystemNode[files.length];
    22:       for (int i = 0; i < files.length; i++)
    23:       {
    24:          if (files[i].isDirectory())
    25:             children[i] = new DirectoryNode(files[i]);
    26:          else
    27:             children[i] = new FileNode(files[i]);
    28:       }
    29:       return children;
    30:    }
    31:
    32:    private File directory;
    33: }