I know that using File
object we can get the last modified time for a File
(i.e. File.lastModified()). But, my requirement is to get the last accessed time for a File
in Java. How do I get it?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You will need to use the new file I/O API (NIO2) which comes with Java 7. It has a method lastAccessTime() for reading the last access time.
Here is a usage example:
For more information see Managing Metadata in the Java Tutorial.
You can't do it with plain Java, you'll need to use JNI to access the platform specific data such as this or use extensions to the core Java library like the following:
Or, if you have Java 7, go with Esko's answer and use NIO.