About question enthuware.ocpjp.v8.2.1543 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

About question enthuware.ocpjp.v8.2.1543 :

Post by javalass »

This is not correct. These attributes are supported by BasicFileAttributes, not BasicFileAttributeView.

javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

Re: About question enthuware.ocpjp.v8.2.1543 :

Post by javalass »

Same problem on question enthuware.ocpjp.v8.2.1777.

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About question enthuware.ocpjp.v8.2.1543 :

Post by admin »

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

javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

Re: About question enthuware.ocpjp.v8.2.1543 :

Post by javalass »

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? :(

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About question enthuware.ocpjp.v8.2.1543 :

Post by admin »

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests