zoukankan
html css js c++ java
Java递归遍历文件夹
手上的这个项目要做一个浏览服务器的功能。用到了这个方法。
Code
1
import
java.io.File;
2
import
java.util.ArrayList;
3
public
class
FileSystem1
{
4
private
static
ArrayList filelist
=
new
ArrayList();
5
6
public
static
void
main(String[] args)
{
7
8
long
a
=
System.currentTimeMillis();
9
refreshFileList(
"
D:\\Tomcat\\webapps\\HaodeWeb\\publish\\Image
"
);
10
System.out.println(System.currentTimeMillis()
-
a);
11
}
12
public
static
void
refreshFileList(String strPath)
{
13
File dir
=
new
File(strPath);
14
File[] files
=
dir.listFiles();
15
16
if
(files
==
null
)
17
return
;
18
for
(
int
i
=
0
; i
<
files.length; i
++
)
{
19
if
(files[i].isDirectory())
{
20
refreshFileList(files[i].getAbsolutePath());
21
}
else
{
22
String strFileName
=
files[i].getAbsolutePath().toLowerCase();
23
System.out.println(
"
---
"
+
strFileName);
24
filelist.add(files[i].getAbsolutePath());
25
}
26
}
27
}
28
}
29
查看全文
相关阅读:
在wubantu时,用pychram创建django的App时,出现未找到命令
Anaconda3 打开Navigator报错
wubantu18.04版,pycharm2.18.3.2永久破解来了,借鉴个位大神的教程破掉的,感谢各位大佬
找回感觉的练习
第四次博客作业-结对项目
第9次作业--接口及接口回调
第8次作业--继承
软件工程第三次作业——关于软件质量保障初探
第7次作业--访问权限、对象使用
第6次作业--static关键字、对象
原文地址:https://www.cnblogs.com/coffee/p/1502621.html
最新文章
top命令使用详解
yum源配置
Linux常用命令大全
Linux渗透与提权:技巧总结篇
细说linux挂载——mount(一)
linux开机启动五部曲
linux上挂载存储测试
在Ubuntu上安装docker常见问题
php用form提交表单数据
PHP 全局变量2
热门文章
Global和LOCAL作用域
php 变量
php 能做什么?
php 在html中嵌入PHP
猎上网电话面试总结
UITextField
UILabel 的属性
iOS 一些UI控件的属性
POSIX信号处理
套接口编程简介
Copyright © 2011-2022 走看看