The DosFileAttributes Interface – Java I/O: Part II

The DosFileAttributes Interface

As the DosFileAttributes interface is a subinterface of the BasicFileAttributes interface, a DosFileAttributes object has both the basic set of file attributes and the DOS-specific file attributes. Its usage is analogous to the PosixFileAttributes interface discussed earlier (p. 1332).

Click here to view code image

interface java.nio.file.attribute.DosFileAttributes
          extends BasicFileAttributes
boolean isReadOnly()
boolean isSystem()
boolean isArchive()
boolean isHidden()

Determine whether the file entry is of a specific kind.

File Attribute Views

Table 21.12 summarizes the file attribute views that different interfaces provide for readable or updatable access to file attributes, in contrast to the file attributes interfaces in Table 21.11, p. 1330, that allow readonly access. The BasicFileAttribute-View interface allows access to the basic set of file attributes that are common to many file systems. Its two subinterfaces, PosixFileAttributeView and DosFileAttributeView, additionally allow access to file attributes associated with POSIX-based and DOS-based file systems, respectively.

An object of the appropriate view interface pertaining to a specific directory entry is returned by the Files.getFileAttributeView() method. All file interface views provide a readAttributes() method that returns the readonly file attributes object associated with the view.

Table 21.12 Selected File Attribute Views

Updatable file attribute view interfaces in the java.nio.file.attribute package.Note that when the view is created, it is opened on a specific directory entry in the file system. The view provides information about file attributes associated with this directory entry.
AttributeViewCan read or update non-opaque values associated with directory entries in a file system.
FileAttributeView extends AttributeViewCan read or update file attributes.
FileOwnerAttributeView extends FileAttributeViewCan read or update the owner.
BasicFileAttributeView extends FileAttributeView Corresponding readonly file attributes interface: BasicFileAttributesCan read or update a basic set of file attributes. Can obtain a readonly BasicFileAttributes object via the view. Can set a timestamp for when the directory entry was last modified, last accessed, and created. (p. 1334)
PosixFileAttributeView extends BasicFileAttributeView, FileOwnerAttributeView Corresponding read-only file attributes interface: PosixFileAttributesCan read or update POSIX file attributes. Can obtain a read-only PosixFileAttributes object via the view. Can set group and file permissions, and update the owner. (p. 1336)
DosFileAttributeView extends BasicFileAttributeView Corresponding read-only file attributes interface: DosFileAttributesCan read or update DOS file attributes. Can obtain a read-only DosFileAttributes object via the view. Can set archive, hidden, read-only, and system attributes. (p. 1338)
Categories: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *