Reads the value of a file attribute.
package com.logicbig.example.files;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class GetAttributeExample {
public static void main(String... args) throws IOException {
Path tempFile = Files.createTempFile("test-file", ".txt");
Object attribute = Files.getAttribute(tempFile, "basic:creationTime");
System.out.println(attribute);
Object readOnly = Files.getAttribute(tempFile, "dos:readonly");
System.out.println(readOnly);
}
}
Output
2017-12-11T03:41:19.264013Z
false