public class Main {
public static void main(String[] args) throws IOException {
File f=new File("E:\\BaiduNetdiskDownload");
String b="\t";
int depth=0;
printFile(f,b,depth);
}
static void printFile(File f,String b,int depth) {
if(f.isFile()) {
System.out.println(b.repeat(depth)+f.getName());
}else if(f.isDirectory()){
System.out.println(b.repeat(depth)+f.getName()+"/");
for(File ff:f.listFiles()) {
printFile(ff,b,depth+1);
Sign in to make a reply
Arthur
public class Main {
public static void main(String[] args) throws IOException {
File f=new File("E:\\BaiduNetdiskDownload");
String b="\t";
int depth=0;
printFile(f,b,depth);
}
static void printFile(File f,String b,int depth) {
if(f.isFile()) {
System.out.println(b.repeat(depth)+f.getName());
}else if(f.isDirectory()){
System.out.println(b.repeat(depth)+f.getName()+"/");
for(File ff:f.listFiles()) {
printFile(ff,b,depth+1);
}
}
}
}