printEntry
public class Tree { private static int actIndent = 0; public static void main(String[] args) { File root = new File("c:/temp/applet/"); printTree(root); } private static void printTree(File root) { printEntry(root); actIndent++; File[] files = root.listFiles(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { printTree(files[i]); } else { printEntry(files[i]); } } actIndent--; } private static void printEntry(File file) { for (int indent = 0; indent < actIndent; indent++) { System.out.print(" "); } if (file.isDirectory()) { System.out.println("<dir > " + file.getName()); System.out.println(" ."); System.out.println(" .."); } else { System.out.println("<file> " + file.getName()); } }}