Java File class represents the files and directory pathnames in an abstract manner. This category is employed for the creation of files and directories, file looking out, file deletion, etc. The File object represents the particular file/directory on the disk.
import java.io.File; public class FileDemo { public static void main(String[] args) { File f = null; String[] strs = {"test1.txt", "test2.txt"}; try { for(String s:strs ) { f = new File(s); boolean bool = f.canExecute(); String a = f.getAbsolutePath(); System.out.print(a); System.out.println(" is executable: "+ bool); } } catch (Exception e) { e.printStackTrace(); } } }
/home/cg/root/2880380/test1.txt is executable: false /home/cg/root/2880380/test2.txt is executable: false