Java-Get Specific File Properties

Get Specific File Properties

File defines many methods that obtain the standard properties of a File object. For example, canWrite( ) method Tests whether the application can modify the file, canRead( ) method Tests whether the application can read the file, isHidden( ) method Tests whether the file named by this abstract pathname is a hidden file, toString( ) method returns the pathname string of this abstract pathname, and length( ) method returns the size of the file in bytes.

Program

0

Program Source 

import java.io.File;

public class Javaapp {

    public static void main(String[] args) {
        
        File f1 = new File("F:\\java8\\program.txt");
        System.out.println("program.txt is writeable   : "+f1.canWrite());
        System.out.println("program.txt is readable    : "+f1.canRead());
        System.out.println("program.txt size in Bytes  : "+f1.length());
        System.out.println("Absolute Location          : "+f1.toString());
        System.out.println("program.txt is Hidden      : "+f1.isHidden());        
    }
}

Leave a Comment