Skip to content

Commit d7c82be

Browse files
committed
Package documentation
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140400 13f79535-47bb-0310-9956-ffa450edef68
1 parent 985c183 commit d7c82be

1 file changed

Lines changed: 115 additions & 0 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<html>
2+
<body>
3+
<p>This package defines an interface (IOFileFilter) that combines both
4+
{@link java.io.FileFilter} and {@link java.io.FilenameFilter}. Besides
5+
that the package offers a series of ready-to-use implementations of the
6+
IOFileFilter interface including implementation that allow you to combine
7+
other such filters.</p>
8+
<p>These filter can be used to list files or in {@link java.awt.FileDialog},
9+
for example.</p>
10+
11+
<p>There are four "primitive" FilenameFilters:</p>
12+
13+
<table>
14+
<tbody>
15+
<tr>
16+
<td><a href="DirectoryFileFilter.html">DirectoryFilter</a></td>
17+
<td>Only accept directories</td>
18+
</tr>
19+
<tr>
20+
<td><a href="PrefixFileFilter.html">PrefixFileFilter</a></td>
21+
<td>Filter based on a prefix</td>
22+
</tr>
23+
<tr>
24+
<td><a href="SuffixFileFilter.html">SuffixFileFilter</a></td>
25+
<td>Filter based on a suffix</td>
26+
</tr>
27+
<tr>
28+
<td><a href="NameFileFilter.html">NameFileFilter</a></td>
29+
<td>Filter based on a filename</td>
30+
</tr>
31+
32+
</tbody>
33+
</table>
34+
35+
<p>And there are five "boolean" FilenameFilters:</p>
36+
37+
<table>
38+
<tbody>
39+
<tr>
40+
<td><a href="TrueFileFilter.html">TrueFileFilter</a></td>
41+
<td>Accept all files</td>
42+
</tr>
43+
<tr>
44+
<td><a href="FalseFileFilter.html">FalseFileFilter</a></td>
45+
<td>Accept no files</td>
46+
</tr>
47+
<tr>
48+
<td><a href="NotFileFilter.html">NotFileFilter</a></td>
49+
<td>Applies a logical NOT to an existing filter</td>
50+
</tr>
51+
<tr>
52+
<td><a href="AndFileFilter.html">AndFileFilter</a></td>
53+
<td>Combines two filters using a logical AND</td>
54+
</tr>
55+
<tr>
56+
<td><a href="OrFileFilter.html">OrFileFilter</a></td>
57+
<td>Combines two filter using a logical OR</td>
58+
</tr>
59+
60+
</tbody>
61+
</table>
62+
63+
<p>These boolean FilenameFilters can be nested, to allow arbitrary expressions.
64+
For example, here is how one could print all non-directory files in the
65+
current directory, starting with "A", and ending in ".java" or ".class":</p>
66+
67+
<pre>
68+
File dir = new File(".");
69+
String[] files = dir.list(
70+
new AndFileFilter(
71+
new AndFileFilter(
72+
new PrefixFileFilter("A"),
73+
new OrFileFilter(
74+
new SuffixFileFilter(".class"),
75+
new SuffixFileFilter(".java")
76+
)
77+
),
78+
new NotdFileFilter(
79+
new DirectoryFileFilter()
80+
)
81+
)
82+
);
83+
for ( int i=0; i&lt;files.length; i++ ) {
84+
System.out.println(files[i]);
85+
}
86+
</pre>
87+
88+
<p>This package also contains a utility class:
89+
<a href="FileFilterUtils.html">FileFilterUtils</a>. It allows you to use all
90+
file filters without having to put the in the import section. Here's how the
91+
above example will look using FileFilterUtils:</p>
92+
<pre>
93+
File dir = new File(".");
94+
String[] files = dir.list(
95+
FileFilterUtils.andFileFilter(
96+
FileFilterUtils.andFileFilter(
97+
FileFilterUtils.prefixFileFilter("A"),
98+
FileFilterUtils.orFileFilter(
99+
FileFilterUtils.suffixFileFilter(".class"),
100+
FileFilterUtils.suffixFileFilter(".java")
101+
)
102+
),
103+
FileFilterUtils.notFileFilter(
104+
FileFilterUtils.directoryFileFilter()
105+
)
106+
)
107+
);
108+
for ( int i=0; i&lt;files.length; i++ ) {
109+
System.out.println(files[i]);
110+
}
111+
</pre>
112+
<p>There are a few other goodies in that class so please have a look at the
113+
documentation in detail.</p>
114+
</body>
115+
</html>

0 commit comments

Comments
 (0)