tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Commons IO > Filters > Readable File Filter

Readable File Filter 

Apache Commons IO is a java library with simple IO utilities and filters. This requires the library commons-io-2.1.jar to be in classpath. The following example shows using CanReadFileFilter.CAN_READ filter. It returns TRUE if the file is readable by this application.


File Name  :  
com/bethecoder/tutorials/commons_io/tests/filters/ReadableFileFilter.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.commons_io.tests.filters;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.filefilter.CanReadFileFilter;

public class ReadableFileFilter {

  /**
   @param args
   @throws IOException 
   */
  public static void main(String[] args) {
    File directory = new File("C:/input");
    
    String[] files = directory.list(CanReadFileFilter.CAN_READ);
     for (String file : files) {
         System.out.println(file);
     }
  }
}
   

It gives the following output,
ascii_table.bmp
console.png
db.png
hidden_file.txt
one.css
readonly_file.txt
Test.class
three.css
two.css
writable_file.txt



 
  


  
bl  br