|
Posted on
2012-02-12 19:42
阳光VIP
阅读( 282)
评论()
编辑
收藏
举报
java 代码
- package guo;
-
- import java.io.File;
-
- public class FileDemo {
-
-
-
-
-
- public static void listFile(String path, int space) {
- File file = new File(path);
- if (file.isFile()) {
- for (int i = 0; i < space; i++) {
- System.out.print(" ");
- }
- System.out.println("--" + file.getName());
- } else {
-
- for (int i = 0; i < space; i++) {
- System.out.print(" ");
- }
- space += space;
- System.out.println("--" + file.getName());
- File files[] = file.listFiles();
- for (int i = 0; i < files.length; i++) {
-
- listFile(files[i].getPath(), space);
- }
-
- }
- }
-
- public static void main(String[] args) {
- FileDemo.listFile("C:", 1);
-
- }
-
- }
|