1 11 package org.eclipse.jdt.internal.compiler.batch; 12 13 import java.io.File ; 14 import java.util.ArrayList ; 15 16 public class FileFinder { 17 18 public static String [] find(File f, String pattern) { 19 ArrayList files = new ArrayList (); 20 find0(f, pattern, files); 21 String [] result = new String [files.size()]; 22 files.toArray(result); 23 return result; 24 } 25 private static void find0(File f, String pattern, ArrayList collector) { 26 if (f.isDirectory()) { 27 String [] files = f.list(); 28 if (files == null) return; 29 for (int i = 0, max = files.length; i < max; i++) { 30 File current = new File (f, files[i]); 31 if (current.isDirectory()) { 32 find0(current, pattern, collector); 33 } else { 34 if (current.getName().toUpperCase().endsWith(pattern)) { 35 collector.add(current.getAbsolutePath()); 36 } 37 } 38 } 39 } 40 } 41 } 42 | Popular Tags |