- private static List<File> FindFile(File file, String key_search)
- {
- List<File> list = new ArrayList<File>();
- if (file.isDirectory()) {
- File[] all_file = file.listFiles();
- if (all_file != null) {
- for (File tempf : all_file) {
- if (tempf.isDirectory()) {
- if (tempf.getName().toLowerCase().lastIndexOf(key_search) > -1) {
- list.add(tempf);
- }
- list.addAll(FindFile(tempf, key_search));
- }
- else
- {
- if (tempf.getName().toLowerCase().lastIndexOf(key_search) > -1) {
- list.add(tempf);
- }
- }
- }
- }
- }
- return list;
- }
- //该片段来自于http://www.codesnippet.cn/detail/090620133953.html
来源: http://www.codesnippet.cn/detail/090620133953.html