public ArrayList<String> list = new ArrayList<String>(0);//用arraylist保存扫描到的路径
public void Scan(String path) {
File file = new File(path);
File[] files = file.listFiles();
String[] filenames = file.list();
if (filenames == null)
return;
for (int i = 0; i < filenames.length; i++) {
if (files[i].isFile()) {
if (files[i].getName().endsWith(“png”))//只获取带png结尾的文件
list.add(files[i].getPath());//获取路径
} else if (files[i].isDirectory()) {
Scan(files[i].getPath());
}
}
}

相关文章:

  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-12-23
  • 2021-12-31
相关资源
相似解决方案