俊星的BLOG
導航
BlogJava
首頁
新隨筆
聯系
聚合
管理
<
2009年5月
>
日
一
二
三
四
五
六
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
統計
隨筆 - 50
文章 - 0
評論 - 6
引用 - 0
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆分類
代碼庫(7)
(rss)
隨筆檔案
2010年11月 (3)
2010年10月 (12)
2009年6月 (5)
2009年5月 (22)
2009年4月 (8)
最新隨筆
1.?實現變更統計
2.?切換IE8中碰到的問題
3.?發布FWMS
4.?ActiveMQ初探
5.?CAS初步配置
搜索
最新評論
1.?re: JAVA圖像縮放處理[未登錄]
不錯的方法
--test
2.?re: freetts初探
學習了! 就是不清楚為啥在eclipse下跑不起來...
--apiao
3.?re: freetts初探
System property "mbrola.base" is undefined. Will not use MBROLA voices.
這個問題怎么解決啊?
--瓏兒
4.?re: ActiveMQ初探
測試通過。多謝
--71569973
5.?登錄網站
評論內容較長,點擊標題查看
--ahome
閱讀排行榜
1.?ftp的port和pasv模式(轉)(8030)
2.?JAVA圖像縮放處理(4180)
3.?Nutz初步試用(4109)
4.?Window下FTP命令使用(3518)
5.?freetts初探(3429)
6.?ActiveMQ初探(2906)
7.?MYSQL Access denied 問題的解決(2345)
8.?HTTP Client及HTTPS初探(1989)
9.?JAVA單向加密(MD5,SHA,MAC)(1266)
10.?CAS認證初探(1152)
評論排行榜
1.?freetts初探(2)
2.?HTTP Client及HTTPS初探(2)
3.?ActiveMQ初探(1)
4.?JAVA圖像縮放處理(1)
5.?我的DWR之DefaultContainer(0)
我的JAVA工具之目錄結構輸出
1、代碼:
package
test;
import
java.io.File;
public
class
DMain {
static
int
level
=
0
;
/**
文件目錄迭代輸出
*/
static
void
pathPrint1(String root) {
File path
=
new
File(root);
if
(path.isDirectory()) {
System.out.println(getMultiStr(
"
"
, level)
+
(path.isDirectory()
?
"
<dir>
"
:
""
)
+
path.getName());
level
++
;
File[] files
=
path.listFiles();
for
(File f : files) {
if
(f.isDirectory()) {
pathPrint1(f.getAbsolutePath());
}
else
{
System.out.println(getMultiStr(
"
"
, level)
+
f.getName());
}
}
level
--
;
}
}
static
String getMultiStr(String str,
int
num) {
String s
=
""
;
for
(
int
i
=
0
; i
<
num; i
++
) {
s
+=
str;
}
return
s;
}
/**
以樹形結構輸出目錄
*/
static
void
printTree(String root, String init) {
File path
=
new
File(root);
if
(path.isDirectory()) {
File[] files
=
path.listFiles();
for
(
int
i
=
0
, length
=
files.length; i
<
length; i
++
) {
File f
=
files[i];
System.out.println(init
+
"
|
"
+
getMultiStr(
"
-
"
,
4
)
+
f.getName());
if
(f.isDirectory()) {
printTree(f.getAbsolutePath(), init
+
(i
==
length
-
1
?
"
"
:
"
|
"
)
+
getMultiStr(
"
"
,
4
));
}
}
}
}
public
static
void
main(String[] args) {
String s
=
"
D:\\My Documents\\discuz!\\Discuz_7[1].0.0_SC_GBK\\upload\\forumdata
"
;
pathPrint1(s);
System.out.println(
"
------------------------
"
);
System.out.println(
"
ROOT
"
);
printTree(s,
""
);
}
}
2、得到的輸出:
<dir>forumdata
<dir>cache
index.htm
index.htm
<dir>logs
index.htm
<dir>templates
index.htm
<dir>threadcaches
index.htm
------------------------
ROOT
|----cache
| |----index.htm
|----index.htm
|----logs
| |----index.htm
|----templates
| |----index.htm
|----threadcaches
|----index.htm
posted on 2009-05-18 20:18
俊星
閱讀(197)
評論(0)
編輯
收藏
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
Powered by:
BlogJava
Copyright © 俊星
主站蜘蛛池模板:
亚洲国产成人a精品不卡在线
|
亚洲中文久久精品无码
|
免费人成再在线观看网站
|
两个人www免费高清视频
|
亚洲嫩模在线观看
|
在线免费观看韩国a视频
|
大地资源在线资源免费观看
|
亚洲美女人黄网成人女
|
欧洲美熟女乱又伦免费视频
|
你是我的城池营垒免费观看完整版
|
亚洲欧洲综合在线
|
狠狠色婷婷狠狠狠亚洲综合
|
免费在线观看黄网
|
95免费观看体验区视频
|
永久免费精品影视网站
|
亚洲一区电影在线观看
|
亚洲免费网站观看视频
|
77777亚洲午夜久久多人
|
操美女视频免费网站
|
国产真人无码作爱视频免费
|
亚洲永久精品ww47
|
妞干网在线免费视频
|
3344在线看片免费
|
黄网站在线播放视频免费观看
|
亚洲成av人片在线看片
|
亚洲欧洲美洲无码精品VA
|
免费国产成人高清视频网站
|
99久久99久久免费精品小说
|
免费毛片毛片网址
|
亚洲欧美成人综合久久久
|
亚洲国产综合专区电影在线
|
四虎永久在线精品免费影视
|
免费鲁丝片一级观看
|
在线免费观看亚洲
|
久久久久久久99精品免费观看
|
国产亚洲精彩视频
|
亚洲欧美成人综合久久久
|
亚洲乱码日产精品BD在线观看
|
亚洲国产女人aaa毛片在线
|
狠狠色伊人亚洲综合成人
|
亚洲精品国精品久久99热
|