package test20140715;
import java.io.File;
import org.junit.Test;
/**
* 遍历扫描目录下全部文件并列出
* @author fushihua-wb
* @date 2014-7-15
*/
public class Test2 {
@Test
public void Test2()
{
System.out.println("START");
File file = new File("G:\\日常记录\\20140714");
Test2 t = new Test2();
t.method(file);
System.out.println("END");
}
private void method(File f)
{
File[] FList = f.listFiles();
for (int i = 0; i < FList.length; i++)
{
if (FList[i].isDirectory()==true)
{
method(FList[i]);
}
else
{
System.out.println(FList[i].getAbsolutePath());
}
}
}
private void Test1(){
File file = new File("G:\\日常记录\\20140715");
File[] lf = file.listFiles();
for (int i = 0; i < lf.length; i++) {
System.out.println(lf[i].getName());
}
}
}
转载于:https://www.cnblogs.com/cxchanpin/p/7298776.html