001// Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 002// The Molly framework is freely distributable under the terms of an 003// MIT-style license. For details, see the molly pages web site at: 004// http://www.mollypages.org/. Use, modify, have fun ! 005 006package fc.io.fileselectors; 007 008import java.io.*; 009import java.util.*; 010 011/** 012Filters a list of files and chooses only sub-directories. 013 014@author hursh jain 015@date 3/24/2002 016**/ 017public class DirectorySelector extends ChainedFileSelector 018{ 019//for convenience 020public DirectorySelector() { 021 this(null); 022 } 023 024public DirectorySelector(ChainedFileSelector filter) { 025 super(filter); 026 } 027 028protected boolean thisfilter(File name) { 029 if ( ! name.isDirectory() ) return false; 030 return true; 031 } 032 033public static void main(String[] args) throws Exception 034 { 035 new Test(); 036 } 037 038/** 039Unit Test History 040<pre> 041Class Version Tester Status Notes 0421.0 hj passed 043</pre> 044*/ 045static private class Test { 046Test() throws Exception 047 { 048 File startdir = new File("c:\\temp"); 049 ChainedFileSelector sel = new DirectorySelector(); 050 File[] files = startdir.listFiles(sel); 051 List list = Arrays.asList(files); 052 System.out.println("total="+ list.size() + ", files=" + list); 053 } 054} //~class Test 055 056}