Getting last modified date of a file not the last

2019-08-04 20:25发布

I had copied a file to my android device. When i check it's last modified date with file.lastModified() it returns the date the file was created which is just now. I want the original date when the file was last modified and not copied. I can see this date in windows explorer with the tag Date modified .The file.lastModified() matches with the Date created Tag of the file. If i could get the last Modified Date i can update the file with another file from server after it has been updated by just checking the date. But with created date it is not possible.

1条回答
Emotional °昔
2楼-- · 2019-08-04 21:03

I got Creation date of a document using apache tika in java

Here is my java code to get creation date of document:

public class tikaExample {

    public static void main(String[] args) throws SAXException, TikaException {
        InputStream is = null;

        try {
            is = new BufferedInputStream(new FileInputStream(new File("/home/rahul/Downloads/darknet5.doc")));

            Parser parser = new AutoDetectParser();
            BodyContentHandler handler = new BodyContentHandler();

            Metadata metadata = new Metadata();

            parser.parse(is, handler, metadata, new ParseContext());
            System.out.println("creation date "+metadata.get(Metadata.CREATION_DATE));
            System.out.println("last modify date "+metadata.get(Metadata.LAST_MODIFIED));           
        } catch (IOException e) {
            e.printStackTrace();
        }

and output of this code is :

 creation date 2002-10-16T05:45:00Z
 last modify date 2013-07-01T05:12:00Z

that is creation date and time of file.

查看更多
登录 后发表回答