View Javadoc

1   /* 
2    * Copyright 2002-2006 The Apache Software Foundation
3    * Licensed  under the  Apache License,  Version 2.0  (the "License");
4    * you may not use  this file  except in  compliance with the License.
5    * You may obtain a copy of the License at 
6    * 
7    *   http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed  under the  License is distributed on an "AS IS" BASIS,
11   * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
12   * implied.
13   * 
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.james.util.io;
18  
19  import java.io.File;
20  import java.io.FilenameFilter;
21  
22  /***
23   * This filter accepts <code>File</code>s that are directories.
24   * <p>Eg., here is how to print out a list of the current directory's subdirectories:</p>
25   *
26   * <pre>
27   * File dir = new File(".");
28   * String[] files = dir.list( new DirectoryFileFilter() );
29   * for ( int i=0; i&lt;files.length; i++ )
30   * {
31   *     System.out.println(files[i]);
32   * }
33   * </pre>
34   *
35   * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
36   * @version $Revision: 365582 $ $Date: 2006-01-03 08:51:21 +0000 (mar, 03 gen 2006) $
37   * @since 4.0
38   */
39  public class DirectoryFileFilter
40      implements FilenameFilter
41  {
42      public boolean accept( final File file, final String name )
43      {
44          return new File( file, name ).isDirectory();
45      }
46  }
47  
48