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
查看全文
相关阅读:
Cookie的小知识
ASP.NET 杂记
Ajax方式的Banner总结
客户端·优化
SQL中灵活运用Group by 和 Order by
怎样才能容易更换DB
txt编写第一个控制台程序
ASP.NET MVC3数据绑定到VIEW的方式
XML和Xpath定位小结
ASP.NET 服务器控件对应HTML标签
原文地址:https://www.cnblogs.com/coffee/p/1502621.html
最新文章
Coroutine and Actor model
编译64位boost
Learn Python
Windows.h与Winsock2.h包含顺序问题
3D游戏中对象间常见的交互方式
The mutable default argument in Python
lockfree算法入门
postgresql 常用命令
安装NFS 4
Nginx安装
热门文章
postgresql 安装
Centos源码安装postgresql
CentOS 6.2安装asterisk
java指定某个时间点周期性执行
Linux 时间同步
ODBC 连接 PostgreSQL
集群(cluster)&高可用性(HA)概念
服务器缓存
Razor语法
浏览器缓存
Copyright © 2011-2022 走看看