标签:blog io ar java sp for 文件 div log
package file_op; import java.io.File; public class file_list { static int n =0; /** * @param args */ public static void main(String[] args) { String ifile = "D:\\"; System.out.println(ifile); list(ifile); } public static void list(String sfile){ n++; File f = new File(sfile); File[] l = f.listFiles(); for (int i=0; i<l.length; i++){ for(int j=0; j<n; j++){ System.out.print(" "); } if (l[i].isFile()){ System.out.println(l[i].getName()); } else if (l[i].isDirectory()){ System.out.println( l[i].getName() + ‘\\‘); list(l[i].getAbsolutePath()); } } n--; } }
标签:blog io ar java sp for 文件 div log
原文地址:http://www.cnblogs.com/mstk/p/4090647.html