// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.*;

public class DirTree {

   public static void main(String[] argv) {
      for (int i = 0; i < argv.length; i++) {
         process("", argv[i]);
      }
   }

   private static void process(String indent, String name) {
      File f = new File(name);
      if (f.isDirectory()) {
         System.out.println(indent + "[" + f.getName() + "]");
         String list[] = f.list();
         for (int i = 0; i < list.length; i++) {
            process(indent + "  ", name + f.separator + list[i]);
         }
      } else if (f.isFile()) {
         System.out.println(indent + f.getName());
      }
   }
}
