Class EmptyFileFilter

  • All Implemented Interfaces:
    java.io.Serializable, FileFilter

    public class EmptyFileFilter
    extends java.lang.Object
    implements FileFilter, java.io.Serializable
    This filter accepts files or directories that are empty.

    If the File is a directory it checks that it contains no files.

    Example, showing how to print out a list of the current directory's empty files/directories:

     FileSystemManager fsManager = VFS.getManager();
     FileObject dir = fsManager.toFileObject(new File("."));
     FileObject[] files = dir.findFiles(new FileFilterSelector(EmptyFileFilter.EMPTY));
     for (int i = 0; i < files.length; i++) {
         System.out.println(files[i]);
     }
     

    Example, showing how to print out a list of the current directory's non-empty files/directories:

     FileSystemManager fsManager = VFS.getManager();
     FileObject dir = fsManager.toFileObject(new File("."));
     FileObject[] files = dir.findFiles(new FileFilterSelector(EmptyFileFilter.NOT_EMPTY));
     for (int i = 0; i < files.length; i++) {
         System.out.println(files[i]);
     }
     
    Since:
    2.4
    Author:
    This code was originally ported from Apache Commons IO File Filter
    See Also:
    "https://commons.apache.org/proper/commons-io/", Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static FileFilter EMPTY
      Singleton instance of empty filter.
      static FileFilter NOT_EMPTY
      Singleton instance of not-empty filter.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected EmptyFileFilter()
      Restrictive constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(FileSelectInfo fileSelectInfo)
      Checks to see if the file is empty.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY

        public static final FileFilter EMPTY
        Singleton instance of empty filter.
    • Constructor Detail

    • Method Detail

      • accept

        public boolean accept​(FileSelectInfo fileSelectInfo)
                       throws FileSystemException
        Checks to see if the file is empty. A non-existing file is also considered empty.
        Specified by:
        accept in interface FileFilter
        Parameters:
        fileSelectInfo - the file or directory to check
        Returns:
        true if the file or directory is empty, otherwise false.
        Throws:
        FileSystemException - Thrown for file system errors.