获取使用BasicFileAttributes在Java SDK的1.8上次文件访问时间 [英] Getting last file access time using BasicFileAttributes in Java SDK 1.8
问题描述
我看到这里的大多数关于Java 1.7的previous问题并获得最后的文件访问时间。
I have seen most of the previous questions here on Java 1.7 and getting the last file access time.
下面也上导入库一个很好的片段,以及它们如何获得最后的文件访问时间:的 http://kodejava.org/how-do-i-get-file-basic-attributes/
Here's also a good snippet on import library and how they get the last file access time: http://kodejava.org/how-do-i-get-file-basic-attributes/
我这样做:
BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
FileTime time = attrs.lastAccessTime();
不过,在我的IntelliJ IDEA的IDE它说,BasicFileAttributes无法解析。
However, in my IntelliJ IDEA IDE it says, BasicFileAttributes could not be resolved.
所以,我进口了:
import java.nio.file.attribute.BasicFileAttributes;
但很显然,文件不能被解决。我正在运行的Java SDK 1.8,我想在我的Android项目中使用这个,如果有差别。
But apparently, file cannot be resolved. I am running Java SDK 1.8 and I am trying to use this in my Android project if that makes a difference.
不知道为什么文件丢失在库中。
Not sure why file is missing in the library.
还有什么我是做错了什么?
What could I be doing wrong?
推荐答案
目前Android不支持所有Java 7的功能以至于忘记了有关Java 8.我提到的Java 7,因为文件
在Java 7中的某些功能被引入像多抓
由Android(和奇巧开始支持尝试-与资源
),但文件
类是没有的。请注意,谷歌不使用Oracle的Java。
Currently Android doesn't support all Java 7 features so forget about Java 8. I mentioned Java 7 because Files
was introduced in Java 7. Some features like multi-catch
are supported by Android(and starting with Kitkat try-with-resources
) but Files
class is not. Note that Google doesn't use Oracle Java.
这篇关于获取使用BasicFileAttributes在Java SDK的1.8上次文件访问时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!