About question enthuware.ocpjp.v8.2.1543 :
Moderator: admin
-
- Posts: 54
- Joined: Thu Mar 03, 2016 1:26 pm
- Contact:
About question enthuware.ocpjp.v8.2.1543 :
This is not correct. These attributes are supported by BasicFileAttributes, not BasicFileAttributeView.
-
- Posts: 54
- Joined: Thu Mar 03, 2016 1:26 pm
- Contact:
Re: About question enthuware.ocpjp.v8.2.1543 :
Same problem on question enthuware.ocpjp.v8.2.1777.
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About question enthuware.ocpjp.v8.2.1543 :
While BasicFileAttributes indeed defines the constants, the attributes of a given file are provided by "views", which in this case is BasicFileAttributeView. If a file system implements a particular "view", it must provide the values of the attributes supported by that view.
Explained here:
https://docs.oracle.com/javase/7/docs/a ... eView.html
or
https://docs.oracle.com/javase/8/docs/a ... eView.html
Explained here:
https://docs.oracle.com/javase/7/docs/a ... eView.html
or
https://docs.oracle.com/javase/8/docs/a ... eView.html
-
- Posts: 54
- Joined: Thu Mar 03, 2016 1:26 pm
- Contact:
Re: About question enthuware.ocpjp.v8.2.1543 :
You're correct, that's what the documentation says.
I still don't understand it though. BasicFileAttributeView only has 3 methods: name(), readAttributes() and setTimes(). BasicFileAttributes defines methods which return the attributes in question: isDirectory(), LastAccessedTime(), creationTime() and so on. The usual way to access these attributes by calling readAttributes() on a BasicFileAttributeView, then calling isFile(), isDirectory(), etc, on the BasicFileAttributes instance returned.
Now why does the documentation say that it's the BasicFileAttributeView that supports these attributes, not BasicFileAttributes?
I still don't understand it though. BasicFileAttributeView only has 3 methods: name(), readAttributes() and setTimes(). BasicFileAttributes defines methods which return the attributes in question: isDirectory(), LastAccessedTime(), creationTime() and so on. The usual way to access these attributes by calling readAttributes() on a BasicFileAttributeView, then calling isFile(), isDirectory(), etc, on the BasicFileAttributes instance returned.
Now why does the documentation say that it's the BasicFileAttributeView that supports these attributes, not BasicFileAttributes?

-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About question enthuware.ocpjp.v8.2.1543 :
I think it is just a matter of interpretation. BasicFileAttributes is a conduit that allows you to retrieve the attribute values but the support for the values is actually provided by the underlying view, which is BasicFileAttributeView.
It is same as saying, "which attributes are supported by a Posix based file system?" Would you argue here that the attributes are supported by PosixFileAttributes and not by the file system?
I don't think it is a big issue here because the question is purely theoretical and not code based. Of course, if you were presented with a code snippet that contained BasicFileAttributeView.creationTime() or something, that would have been incorrect.
HTH,
Paul.
It is same as saying, "which attributes are supported by a Posix based file system?" Would you argue here that the attributes are supported by PosixFileAttributes and not by the file system?
I don't think it is a big issue here because the question is purely theoretical and not code based. Of course, if you were presented with a code snippet that contained BasicFileAttributeView.creationTime() or something, that would have been incorrect.
HTH,
Paul.
Who is online
Users browsing this forum: No registered users and 3 guests