当前位置:早雪网网络学院编程文档Java → 文件夹下目录文件的迭代现实示例2

文件夹下目录文件的迭代现实示例2

减小字体 增大字体 作者:不详  来源:supcode.com收集整理  发布时间:2005-7-22 18:46:52
package math;
import java.io.*;

public class Test {
    public static String List(File f) {
        String optionStr = null;
        String tempStr = null;
        String cc2 = f.getPath().toString();
        //System.out.println(cc2);
        optionStr = "<option >" + cc2 + "</option>";
        String[] name = f.list();
        for (int i = 0; i < name.length; i++) {
            File n = new File(f, name[i]);
            if (n.isDirectory())
                tempStr = List(n);
            if (tempStr == null) {
                tempStr = " ";
            }

            String cc1 = f.getParent().toString();
            String cc = f.getPath().toString();
            if (cc != cc2) {
                //System.out.println(f.getPath());
            }
            optionStr = optionStr + tempStr;
        }
        return optionStr;
    }

    public static void main(String[] s) {
        System.out.println(
            List(
                new File("D:\\ea\\wlserver6.0\\config\\WLSD11\\applications\\LabsWebApp")));
    }
}
[数据载入中...] [返回上一页] [打 印]