// 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 DirTree2 {

   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);
      System.out.println(indent + "[" + f.getName() + "]");
      String list[] = f.list();
      for (int i = 0; i < list.length; i++) {
         String name2 = name + f.separator + list[i];
         if ((new File(name2)).isFile()) {
            System.out.println(indent + "  " + list[i]);
         }
      }
      for (int i = 0; i < list.length; i++) {
         String name2 = name + f.separator + list[i];
         if ((new File(name2)).isDirectory()) {
            process(indent + "  ", name2);
         }
      }
   }
}
