3:13 pm - Sunday December 17, 4800

Creating Programs For Check the file are Execute boolean canExecute()

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 are Execute.

EXAMPLE PROGRAM


import java.io.*;

public class FileCanExe {

public static void main(String[] args) {

File f = null;

String files[] = { "porpert.Xml", "b.txt" };

for (String s : files) {

f = new File(s);

boolean bool = f.canExecute();

String path = f.getAbsolutePath();

System.out.print(path);

System.out.println("is execute:" + bool);

}

}

}

 

Output

 

D:\Documents and Settings\Admin\MadhanTask\TasksCore\porpert.Xmlis execute:true

D:\Documents and Settings\Admin\MadhanTask\TasksCore\b.txtis execute:false

Explanation

 

lean canExecute()

 

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

 

Returns:

   true if and only if the abstract pathname exists and the application is allowed to execute the file

 

Throws:

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

 

Since:

   1.6

BACK

Filed in: Z-A All Java Codes

Comments are closed.