Java examples for File Path IO:DOS File
DosFileAttributeView view extends the basic view with the DOS attributes.
There are four attributes, which are mapped by the following methods:
The following listing extracts in bulk the preceding four attributes for a given path:
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.DosFileAttributes; public class Main { public static void main(String[] args) { DosFileAttributes attr = null; Path path = Paths.get("C:/folder1/folder2/folder4", "test.txt"); try {//from w ww .j ava 2s .c o m attr = Files.readAttributes(path, DosFileAttributes.class); } catch (IOException e) { System.err.println(e); } System.out.println("Is read only ? " + attr.isReadOnly()); System.out.println("Is Hidden ? " + attr.isHidden()); System.out.println("Is archive ? " + attr.isArchive()); System.out.println("Is system ? " + attr.isSystem()); } }