This example shows how to obtain the content of a directory including its subdirectories.

 import java.io.*;
import java.util.*;
public class DirUtils {

  public static List recurseDir(String dir) {
      String result, _result[];

      result = recurseInDirFrom(dir);
      _result = result.split("\\|");
      return Arrays.asList(_result);
  }

  private static String recurseInDirFrom(String dirItem) {
    File file;
    String list[], result;

    result = dirItem;

    file = new File(dirItem);
    if (file.isDirectory()) {
      list = file.list();
      for (int i = 0; i < list.length; i++)
        result = result + "|" + recurseInDirFrom(dirItem + File.separatorChar + list[i]);
      }
    return result;
  }

  public static void main(String arg[]) {
    if (arg.length > 0) {
      System.out.println("recursive Dirs from " + arg[0]);
      System.out.println(DirUtils.recurseDir(arg[0]));
    }
    else {
      System.out.println("Usage :");
      System.out.println("  java DirUtils c:\temp");
    }
    
  }
}