package.html revision a07f2ae0b18964aa15e218e8b6be8be24e5c9f46
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<!--
3Licensed to the Apache Software Foundation (ASF) under one or more
4contributor license agreements.  See the NOTICE file distributed with
5this work for additional information regarding copyright ownership.
6The ASF licenses this file to You under the Apache License, Version 2.0
7(the "License"); you may not use this file except in compliance with
8the License.  You may obtain a copy of the License at
9
10     http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing, software
13distributed under the License is distributed on an "AS IS" BASIS,
14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15See the License for the specific language governing permissions and
16limitations under the License.
17-->
18<html>
19<body>
20<p>This package defines an interface (IOFileFilter) that combines both 
21{@link java.io.FileFilter} and {@link java.io.FilenameFilter}. Besides
22that the package offers a series of ready-to-use implementations of the
23IOFileFilter interface including implementation that allow you to combine
24other such filters.</p>
25<p>These filter can be used to list files or in {@link java.awt.FileDialog}, 
26for example.</p>
27     
28<p>There are a number of 'primitive' filters:</p>
29     
30<table>
31       <tbody>
32    <tr>
33      <td><a href="DirectoryFileFilter.html">DirectoryFilter</a></td>
34      <td>Only accept directories</td>
35    </tr>
36       <tr>
37      <td><a href="PrefixFileFilter.html">PrefixFileFilter</a></td>
38      <td>Filter based on a prefix</td>
39    </tr>
40       <tr>
41      <td><a href="SuffixFileFilter.html">SuffixFileFilter</a></td>
42      <td>Filter based on a suffix</td>
43    </tr>
44    <tr>
45      <td><a href="NameFileFilter.html">NameFileFilter</a></td>
46      <td>Filter based on a filename</td>
47    </tr>
48    <tr>
49      <td><a href="WildcardFileFilter.html">WildcardFileFilter</a></td>
50      <td>Filter based on wildcards</td>
51    </tr>
52    <tr>
53      <td><a href="AgeFileFilter.html">AgeFileFilter</a></td>
54      <td>Filter based on last modified time of file</td>
55    </tr>
56    <tr>
57      <td><a href="SizeFileFilter.html">SizeFileFilter</a></td>
58      <td>Filter based on file size</td>
59    </tr>
60  </tbody>
61</table>
62     
63<p>And there are five 'boolean' filters:</p>
64     
65<table>
66       <tbody>
67       <tr>
68      <td><a href="TrueFileFilter.html">TrueFileFilter</a></td>
69      <td>Accept all files</td>
70    </tr>
71       <tr>
72      <td><a href="FalseFileFilter.html">FalseFileFilter</a></td>
73      <td>Accept no files</td>
74    </tr>
75       <tr>
76      <td><a href="NotFileFilter.html">NotFileFilter</a></td>
77      <td>Applies a logical NOT to an existing filter</td>
78    </tr>
79    <tr>
80      <td><a href="AndFileFilter.html">AndFileFilter</a></td>
81      <td>Combines two filters using a logical AND</td>
82    </tr>
83       <tr>
84      <td><a href="OrFileFilter.html">OrFileFilter</a></td>
85      <td>Combines two filter using a logical OR</td>
86    </tr>
87     
88  </tbody>
89</table>
90      
91<p>These boolean FilenameFilters can be nested, to allow arbitrary expressions.
92For example, here is how one could print all non-directory files in the
93current directory, starting with "A", and ending in ".java" or ".class":</p>
94     
95<pre>
96  File dir = new File(".");
97  String[] files = dir.list( 
98    new AndFileFilter(
99      new AndFileFilter(
100        new PrefixFileFilter("A"),
101        new OrFileFilter(
102          new SuffixFileFilter(".class"),
103          new SuffixFileFilter(".java")
104        )
105      ),
106      new NotFileFilter(
107        new DirectoryFileFilter()
108      )
109    )
110  );
111  for ( int i=0; i&lt;files.length; i++ ) {
112    System.out.println(files[i]);
113  }
114</pre>
115
116<p>This package also contains a utility class: 
117<a href="FileFilterUtils.html">FileFilterUtils</a>. It allows you to use all 
118file filters without having to put them in the import section. Here's how the 
119above example will look using FileFilterUtils:</p>
120<pre>
121  File dir = new File(".");
122  String[] files = dir.list( 
123    FileFilterUtils.andFileFilter(
124      FileFilterUtils.andFileFilter(
125        FileFilterUtils.prefixFileFilter("A"),
126        FileFilterUtils.orFileFilter(
127          FileFilterUtils.suffixFileFilter(".class"),
128          FileFilterUtils.suffixFileFilter(".java")
129        )
130      ),
131      FileFilterUtils.notFileFilter(
132        FileFilterUtils.directoryFileFilter()
133      )
134    )
135  );
136  for ( int i=0; i&lt;files.length; i++ ) {
137    System.out.println(files[i]);
138  }
139</pre>
140<p>There are a few other goodies in that class so please have a look at the 
141documentation in detail.</p>
142    </body>
143</html>
144