I have a question on a quiz question that I found on the cd (book K&B7).
Given this code:
which compile and run without error in Windows?
The possibilities of choice are:
A - BasicFileAttributes attr = Files.readAttributes(dir, BasicFileAttributes.class);
B - BasicFileAttributes attr = Files.readAttributes(dir, DosFileAttributes.class);
C - DosFileAttributes attr = Files.readAttributes(dir, BasicFileAttributes.class);
D - DosFileAttributes attr = Files.readAttributes(dir, DosFileAttributes.class);
E - BasicFileAttributes attr = new BasicFileAttributes(dir);
F - BasicFileAttributes attr = dir.getBasicFileAttributes();
I can not understand why A and B are incorrect.
The solution gives this explanation:
A and B are incorrect because the archive attribute only exists on the Windows platform. The code fails to compile since archive is not found on BasicFileAttributes.
But I just can not understand the logical link with archive attribute.