KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > find > FindFile


1 package find;
2
3 import version.Version;
4 import list.ListFile;
5
6 import java.util.Collection JavaDoc;
7 import java.util.ArrayList JavaDoc;
8 import java.io.File JavaDoc;
9
10 import org.apache.commons.collections.CollectionUtils;
11 import org.apache.commons.collections.Predicate;
12
13 public class FindFile {
14   static {
15     Version.register("find");
16   }
17   
18   public static Collection JavaDoc find(File dir, String JavaDoc name) {
19     return find(ListFile.list(dir), name);
20   }
21   
22   private static Collection JavaDoc find(Collection JavaDoc files, final String JavaDoc name) {
23     return CollectionUtils.select(files, new Predicate() {
24       public boolean evaluate(Object JavaDoc o) {
25         return ((File)o).getName().indexOf(name) != -1;
26       }
27     });
28   }
29 }
30
Popular Tags