Java tutorial
//package com.java2s; import java.io.File; public class Main { private static void dumpFolderRecursive(final File folder, final StringBuilder sb, final int level) { for (int i = 0; i < level; i++) sb.append("\t"); sb.append(folder.getName()); sb.append("\n"); for (File file : folder.listFiles()) { if (file.isDirectory()) dumpFolderRecursive(file, sb, level + 1); else { for (int i = 0; i <= level; i++) sb.append("\t"); sb.append(file.getName()); sb.append("\n"); } } } }