How to get the last modification time of a file in Java

1 Answer

0 votes
package javaapplication1;
 
import java.io.File;
import java.io.IOException;
import java.util.Date;
 
public class JavaApplication1 {
 
    public static void main(String[] args) throws IOException {
 
        try {
 
            File file = new File("d:\\Img_1973_Backup.jpg");
 
            long lastModified = file.lastModified();
 
            System.out.println(new Date(lastModified));
 
        } catch (Exception e) {
            System.out.print(e);
        }
    }
}
 
 
/*
         
run:
   
Sun Nov 13 21:08:41 IST 2016
 
 */

 



answered Nov 17, 2016 by avibootz

Related questions

1 answer 211 views
1 answer 185 views
185 views asked Jun 17, 2016 by avibootz
1 answer 184 views
1 answer 195 views
1 answer 248 views
1 answer 198 views
...