Class CanReadFileFilter

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

    public class CanReadFileFilter
    extends java.lang.Object
    implements FileFilter, java.io.Serializable
    This filter accepts Files that can be read.

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

     FileSystemManager fsManager = VFS.getManager();
     FileObject dir = fsManager.toFileObject(new File("."));
     FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.CAN_READ));
     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 un-readable files:

     FileSystemManager fsManager = VFS.getManager();
     FileObject dir = fsManager.toFileObject(new File("."));
     FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.CANNOT_READ));
     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 read-only files:

     FileSystemManager fsManager = VFS.getManager();
     FileObject dir = fsManager.toFileObject(new File("."));
     FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.READ_ONLY));
     for (int i = 0; i < files.length; i++) {
         System.out.println(files[i]);
     }
     
    Since:
    2.4
    See Also:
    "http://commons.apache.org/proper/commons-io/", Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CanReadFileFilter()
      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 can be read.
      • Methods inherited from class java.lang.Object

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

      • CAN_READ

        public static final FileFilter CAN_READ
        Singleton instance of readable filter.
      • CANNOT_READ

        public static final FileFilter CANNOT_READ
        Singleton instance of not readable filter.
      • READ_ONLY

        public static final FileFilter READ_ONLY
        Singleton instance of read-only filter.
    • Constructor Detail

      • CanReadFileFilter

        protected CanReadFileFilter()
        Restrictive constructor.
    • Method Detail

      • accept

        public boolean accept​(FileSelectInfo fileSelectInfo)
                       throws FileSystemException
        Checks to see if the file can be read.
        Specified by:
        accept in interface FileFilter
        Parameters:
        fileSelectInfo - the File to check.
        Returns:
        true if the file can be read, otherwise false.
        Throws:
        FileSystemException - Thrown for file system errors.