import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
public class GetFileName {
//获取某路径下的文件列表(一个层级)
public static String [] getFileName(String path)
{
File file = new File(path);
String [] fileName = file.list();
return fileName;
}
//获取某路径下的文件列表(迭代的)
public static void getAllFileName(String path, ArrayList<String> fileName)
{
File file = new File(path);
File [] files = file.listFiles();
String [] names = file.list();
if(names != null)
fileName.addAll(Arrays.asList(names));
for(File a:files)
{
if(a.isDirectory())
{
getAllFileName(a.getAbsolutePath(),fileName);
}
}
}
}