Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get file metadata in java

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.23k
    Comment on it

    Hello Guys

    Here, I am writing about extract the metadata of the file in java technology in which you can extract file creation date, file access date, modification date, size etc. Java provide inbuild BasicFileAttributes class in the JDK.

    MetaData is a useful details of the file that is attached with file and metadata have many attributes as below :
    File name
    File creation date
    File access date
    File modification date
    File tag
    File description

    Below example help you to better understand :

     BasicFileAttributes attr = Files.readAttributes("/image/bhagwan.jpg", BasicFileAttributes.class);//Reading basic attribute/metadata of the file
    
             // extracting the attribute/metadata of the file
                    System.out.println("creationTime: " + attr.creationTime());
                    System.out.println("lastAccessTime: " + attr.lastAccessTime());
                    System.out.println("lastModifiedTime: " + attr.lastModifiedTime());             
                    System.out.println("isDirectory: " + attr.isDirectory());
                    System.out.println("isOther: " + attr.isOther());
                    System.out.println("isRegularFile: " + attr.isRegularFile());
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: