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:       for (FileSystemNode c : node.getChildren())
17:          c.accept(this);
18:       level--;
19:    }
20: 
21:    private int level = 0;
22: }