[ Back | Previous | Next ]

How to recursivly do a directory list?

Package:
java.io.*
Product:
JDK
Release:
1.0.2
Related Links:
General
File
FilenameFilter
FileWriter
JPEGCodec
ObjectInputStream
OutputStream
PipedInputStream
PrintWriter
StreamTokenizer
Comment:
/**
 * Insert the method's description here.
 * Creation date: (3/15/00 4:45:34 PM)
 * @return java.io.File[]
 */
public static void listFilesRecursive(Vector list, File root) {
 if (root.isFile()) {
  list.addElement(root);
  return;
 }
 File[] files = root.listFiles();
 for (int i=0; i < files.length; i++) {
  if ( files[i].isFile() && files[i].getName().endsWith(".java")) {
   list.addElement(files[i]);
  }
  if ( files[i].isDirectory()) {
   listFilesRecursive(list,files[i]);
  }
 }
1