import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class Test3 {
private static List<String> dirList = new ArrayList<>();
public static void main(String[] args) {
File file = new File("E:\yht");
getAllDirectoryName(file);
dirList.remove(0);
System.out.println(dirList.size());
for (String str : dirList) {
System.out.println(str);
}
}
public static void getAllDirectoryName(File path) {
if (!path.exists() || !path.isDirectory()) { //不是目录
return;
}
dirList.add(path.getAbsolutePath());
String[] tmpList = path.list();
if (tmpList != null) {
for (String iter : tmpList) {
File tmpFile = new File(path, iter);
if (tmpFile.isDirectory()) {
getAllDirectoryName(tmpFile);
}
}
}
}
}