import java.io.File;
public class test {
public static void main(String[] args) {
String path="D:/javafile";
test.print1(path);
}
public static void print1 (String path){
File config=new File(path);
File temp[];
temp=config.listFiles();//列出目录下的文件及文件夹
for(int i=0;i<temp.length;i++){
if(temp[i].isDirectory()){//判断是否目录,如果是目录则递归回调继续处理改目录下的文件temp[i].getPath()
// System.out.println(temp[i].getPath()+": ");
print1(temp[i].getPath());
}
else {
System.out.println(temp[i].getPath()+": ");
// System.out.println(temp[i].getName());
}
}
}
}