本帖最后由 simonqian 于 2013-5-9 21:26 编辑
package test1;
import java.io.File;
import java.io.IOException;
public class FileDemo
{
public static void main(String[] args) throws IOException
{
File f = new File("d:\\MiOne");
showDir(f);
}
//递归方法
public static void showDir(File f)
{
System.out.println(f);
File[] ff = f.listFiles();
for(int i=0;i<ff.length;i++)
{
if(ff.isDirectory())
showDir(ff);
else
System.out.println(ff);
}
}
}
如果把 File f = new File("d:\\MiOne");改为File f = new File("d:\\");也没有用求解?
|