attributes - BasicFileAttributes vs BasicFileAttributeView in Java -
what difference between these 2 interfaces? basicfileattributes vs basicfileattributeview
i understand serve retrieve basic metadata file, differs each other?
edit: meant in following example 2 interfaces used interchangeably. there difference @ all? besides fact in order access attributes view first have call .readattributes()
method?
basicfileattributeview bs = files.getfileattributeview(path, basicfileattributeview.class); basicfileattributes bfa = files.readattributes(path, basicfileattributes.class);
interfaces nothing signatures describe. difference between these 2 interfaces are, demand methods of other signatures implemented.
if have basicfileattributeview instance, can basicfileattributes using readattributes()
. if don't have basicfileattributeview instance, can using files.getfileattributeview. guaranteed can one, if can't every instance of every subclass of fileattributeview.
example:
basicfileattributeview bfav = files.getfileattributeview( filesystems.getdefault().getpath("/dev/null"), basicfileattributeview.class ); basicfileattributes bfa = bfav.readattributes(); system.out.println(new date(bfa.lastaccesstime().tomillis()));
- we default filesystem, can use in next step.
- we path using filesystem, can use in next step
- we basicfileattributeview (which represents ability read basicfileattribute) using path, ...
- we basicfileattribute using basicfileattributeview, ...
- we lastaccesstime (a filetime), ...
- we milliseconds previous
- we date previous
Comments
Post a Comment