列出目录下所有文件

import java.io.File;

public class ListFilesTest {

public static void main(String[] args) {
    String path = "C:" + File.separator + "Drivers" + File.separator
            + "Audio";
    File file = new File(path);
     print(file);

}

public static void print(File file) {
    if (file != null && file.isDirectory()) {
        File[] arryFiles = file.listFiles();
        for (int i = 0; i < arryFiles.length; i++) {
            print(arryFiles[i]);
        }
    } else {
        System.out.println(file);
    }
}

}

你可能感兴趣的:(FileList)