    01: import java.io.*;
    02:
    03: public class PrintVisitor implements FileSystemVisitor
    04: {
    05:    public void visitFileNode(FileNode node)
    06:    {
    07:       for (int i = 0; i < level; i++) System.out.print(" ");
    08:       System.out.println(node.getFile().getName());
    09:    }
    10:
    11:    public void visitDirectoryNode(DirectoryNode node)
    12:    {
    13:       for (int i = 0; i < level; i++) System.out.print(" ");
    14:       System.out.println(node.getDirectory().getName());
    15:       level++;
    16:       FileSystemNode[] children = node.getChildren();
    17:       for (int i = 0; i < children.length; i++)
    18:          children[i].accept(this);
    19:       level--;
    20:    }
    21:
    22:    private int level = 0;
    23: }