package com.file; import java.io.File; import java.util.Arrays; import org.junit.Test; public class ListDir2 { int indentLevel = -1; String htmlPath = ""; @Test public void listPath() { File path = new File("C:/javazip"); listPath(path); } public void listPath(File path) { File files[]; indentLevel++; files = path.listFiles(); Arrays.sort(files); for (int i = 0, n = files.length; i < n; i++) { for (int indent = 0; indent < indentLevel; indent++) { System.out.print(" "); } File file = files[i]; if (file.isDirectory()) { System.out.println(file.getAbsolutePath()); } else { System.out.println(file.getName()); } if (files[i].isDirectory()) { listPath(files[i]); } } indentLevel--; } }

dapeng0011 LV15
2024年7月17日
神龙摆尾无拘束 LV2
2023年3月18日
氢氧化钠 LV4
2021年7月5日
123456lqh LV1
2021年6月9日
mooremanor LV1
2021年5月26日
jaonsang LV25
2021年3月8日
cs24122 LV1
2020年7月10日
2751292324 LV1
2020年7月8日
707265277 LV1
2020年7月6日
7758520asd LV1
2020年7月3日