1:01 pm - Wednesday February 22, 2017

Creating Programs for Check The File Readable Or not using boolean canRead() method.

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

Creating Programs for Check The File Readable Or not

EXAMPLE PROGRAM

 


import java.io.*;

public class FileCanRead {

	public static void main(String[] args) {

		File f = null;

		f = new File("Prop.xml");

		boolean bool = f.canRead();

		System.out.println("The File Can Read:" + bool);

	}

}

 

Output

 

The File Can Read:true

Explanation

public boolean canRead()

 

Tests whether the application can read the file denoted by this abstract pathname.

 

Returns:

   true if and only if the file specified by this abstract pathname exists and can be read by the application; false otherwise

 

Throws:

   SecurityException – If a security manager exists and its SecurityManager.checkRead(java.lang.String) method denies read access to the file

BACK

Filed in: Z-A All Java Codes

Comments are closed.