Check if file can be read in Java

An example on checking whether a file can be read or not in Java using File class.


class CheckRead
public static void main(String args[])

// Create a File object
File f=new File("");

// Check can be Read
System.out.println("Can file be read (T/F)? "+f.canRead());



Can file be read (T/F)? true

Posted by at on

Tags: Java IO,