view plaincopy to clipboardprint?
import java.io.*;
public class ListFiles {
private static String s = "";
private static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static void main(String[] args) {
try {
s = in.readLine();
getFileList(s);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void getFileList(String directory) {
File f = new File(directory);
File[] files = f.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
System.out.println("文件:" + files[i]);
} else {
System.out.println("目录:" + files[i]);
// System.out.println("目录绝对地址:" + files[i].getAbsolutePath());
getFileList(files[i].getAbsolutePath());
}
}
}
}