- class FileUtil {
- ArrayList<File> fileList = new ArrayList<File>();
- public void fileSearcher(File[] files, String str) {
- for (int i = 0; i < files.length; i++) {
- if (!files[i].getName().endsWith(".BIN")) {
- if (files[i].isDirectory()) {
- fileSearcher(files[i].listFiles(), str);
- } else {
- if (files[i].getName().endsWith(str)) {
- fileList.add(files[i]);
- }
- }
- }
- }
- }
- public File[] fileFilter(File[] files, String str) {
- fileSearcher(files, str);
- File[] fileArray = new File[fileList.size()];
- int i = 0;
- for (File file : fileList) {
- fileArray[i] = file;
- i++;
- }
- return fileArray;
- }
- }
复制代码
|