//in case of text1.txt it is false because i do not make a textt.txt file inside the workspace
//in case of text2.txt it is true because i make a text2.txt file inside the workspace
public class FIleObjectDemo {
public static void main(String[] args) {
File f = null;
String[] fileName = {"test1.txt","test2.txt"};
for (String string : fileName) {
f = new File(string);
boolean bool = f.canExecute(); // true if the file is executable
String a = f.getAbsolutePath(); // find the absolute path
System.out.println(a); // print the absolute path
System.out.println("is Executable: "+ bool + "\n");
}
}
}
--------------------------------------------------------------------------------------------------
// OUTPUT:
// Here first we have to make test2.txt file in the workspace

No comments:
Post a Comment