commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter package.html
Date Sat, 22 Nov 2003 20:04:13 GMT
jeremias    2003/11/22 12:04:13

  Added:       io/src/java/org/apache/commons/io/filefilter package.html
  Log:
  Package documentation
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/package.html
  
  Index: package.html
  ===================================================================
  <html>
    <body>
  <p>This package defines an interface (IOFileFilter) that combines both 
  {@link java.io.FileFilter} and {@link java.io.FilenameFilter}. Besides
  that the package offers a series of ready-to-use implementations of the
  IOFileFilter interface including implementation that allow you to combine
  other such filters.</p>
  <p>These filter can be used to list files or in {@link java.awt.FileDialog}, 
  for example.</p>
       
  <p>There are four "primitive" FilenameFilters:</p>
       
  <table>
         <tbody>
      <tr>
        <td><a href="DirectoryFileFilter.html">DirectoryFilter</a></td>
        <td>Only accept directories</td>
      </tr>
         <tr>
        <td><a href="PrefixFileFilter.html">PrefixFileFilter</a></td>
        <td>Filter based on a prefix</td>
      </tr>
         <tr>
        <td><a href="SuffixFileFilter.html">SuffixFileFilter</a></td>
        <td>Filter based on a suffix</td>
      </tr>
         <tr>
        <td><a href="NameFileFilter.html">NameFileFilter</a></td>
        <td>Filter based on a filename</td>
      </tr>
       
    </tbody>
  </table>
       
  <p>And there are five "boolean" FilenameFilters:</p>
       
  <table>
         <tbody>
         <tr>
        <td><a href="TrueFileFilter.html">TrueFileFilter</a></td>
        <td>Accept all files</td>
      </tr>
         <tr>
        <td><a href="FalseFileFilter.html">FalseFileFilter</a></td>
        <td>Accept no files</td>
      </tr>
         <tr>
        <td><a href="NotFileFilter.html">NotFileFilter</a></td>
        <td>Applies a logical NOT to an existing filter</td>
      </tr>
      <tr>
        <td><a href="AndFileFilter.html">AndFileFilter</a></td>
        <td>Combines two filters using a logical AND</td>
      </tr>
         <tr>
        <td><a href="OrFileFilter.html">OrFileFilter</a></td>
        <td>Combines two filter using a logical OR</td>
      </tr>
       
    </tbody>
  </table>
        
  <p>These boolean FilenameFilters can be nested, to allow arbitrary expressions.
  For example, here is how one could print all non-directory files in the
  current directory, starting with "A", and ending in ".java" or ".class":</p>
       
  <pre>
    File dir = new File(".");
    String[] files = dir.list( 
      new AndFileFilter(
        new AndFileFilter(
          new PrefixFileFilter("A"),
          new OrFileFilter(
            new SuffixFileFilter(".class"),
            new SuffixFileFilter(".java")
          )
        ),
        new NotdFileFilter(
          new DirectoryFileFilter()
        )
      )
    );
    for ( int i=0; i&lt;files.length; i++ ) {
      System.out.println(files[i]);
    }
  </pre>
  
  <p>This package also contains a utility class: 
  <a href="FileFilterUtils.html">FileFilterUtils</a>. It allows you to use all

  file filters without having to put the in the import section. Here's how the 
  above example will look using FileFilterUtils:</p>
  <pre>
    File dir = new File(".");
    String[] files = dir.list( 
      FileFilterUtils.andFileFilter(
        FileFilterUtils.andFileFilter(
          FileFilterUtils.prefixFileFilter("A"),
          FileFilterUtils.orFileFilter(
            FileFilterUtils.suffixFileFilter(".class"),
            FileFilterUtils.suffixFileFilter(".java")
          )
        ),
        FileFilterUtils.notFileFilter(
          FileFilterUtils.directoryFileFilter()
        )
      )
    );
    for ( int i=0; i&lt;files.length; i++ ) {
      System.out.println(files[i]);
    }
  </pre>
  <p>There are a few other goodies in that class so please have a look at the 
  documentation in detail.</p>
      </body>
  </html>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message