Java Reference
In-Depth Information
// Specific attribute views.
DosFileAttributeView view
= Files.getFileAttributeView(path,
DosFileAttributeView.class);
System.out.println("DOS File Attributes\n”);
System.out.println(“------------------------------------\n");
System.out.println("Archive :"+view.readAttributes().isArchive());
System.out.println("Hidden
:"+view.readAttributes().isHidden());
System.out.println("Read-only:"+view.readAttributes().isReadOnly());
System.out.println("System
:"+view.readAttributes().isSystem());
view.setArchive(false);
} catch (IOException e) {
e.printStackTrace();
}
How It Works
Java NIO.2 allows much more flexibility in getting and setting file attributes than older
I/O techniques. NIO.2 abstracts the different operating system attributes into both a
“Common” set of attributes and an “OS Specific” set of attributes. The standard attrib-
utes are the following:
isDirectory : True if it's a directory.
isRegularFile : Returns false if the file isn't considered a regular
file, the file doesn't exist, or it can't be determined whether it's a regular
file.
isSymbolicLink : True if the link is symbolic (most prevalent in
Unix systems).
isHidden : True if the file is considered to be hidden in the operating
system.
LastModifiedTime : The time the file was last updated.
Search WWH ::




Custom Search