/Users/lyon/j4p/src/futils/DirFilter.java

1    package futils; 
2     
3    import java.io.File; 
4    import java.io.FilenameFilter; 
5     
6    public class DirFilter implements FilenameFilter { 
7        public boolean accept(File dir, String name) { 
8            return new File(dir, name).isDirectory(); 
9        } 
10    
11       public static File[] getDirFiles() { 
12           File f = Futil.getReadDirFile("select a file"); 
13           return f.listFiles(new DirFilter()); 
14       } 
15    
16       // Test the DirFilter: 
17       public static void main(String args[]) { 
18           File dirs [] = getDirFiles(); 
19           System.out.println("These are just dirs:"); 
20           for (int i = 0; i < dirs.length; i++) 
21               System.out.println(dirs[i]); 
22       } 
23   } 
24