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--;
	}
}
最近下载更多
神龙摆尾无拘束  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日
LKXcode  LV1 2020年6月25日
最近浏览更多
sunwu5212  LV6 2023年6月28日
神龙摆尾无拘束  LV2 2023年3月18日
包呼和  LV10 2023年2月27日
Dominick  LV14 2022年12月14日
unknown_turtleshell  LV3 2022年5月6日
刘亦菲9527  LV15 2021年11月29日
氢氧化钠  LV4 2021年7月5日
123456lqh  LV1 2021年6月9日
mooremanor  LV1 2021年5月26日
nextstep  LV11 2021年5月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友