Re: 怎样递归操作目录,子目录以及他们下面的文件?# Java - 爪哇娇娃
k*e
1 楼
You can create a method referring to the below code, then
call this method recursively:
File currentDir = new File(String yourDir);
String[] subDirs = currentDir.list(new FilenameFilter(){
public boolean accept(File dir, String name)
{
// add your code here
/*
File tmpFile = new File(name);
return tmpFile.isDirectory();
*/
}
});
call this method recursively:
File currentDir = new File(String yourDir);
String[] subDirs = currentDir.list(new FilenameFilter(){
public boolean accept(File dir, String name)
{
// add your code here
/*
File tmpFile = new File(name);
return tmpFile.isDirectory();
*/
}
});