Files.getAttribute(Path path, String attribute, LinkOption ... options) has the following syntax.
public static Object getAttribute(Path path, String attribute, LinkOption ... options) throws IOException
In the following code shows how to use Files.getAttribute(Path path, String attribute, LinkOption ... options) method.
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; /*from w ww.ja v a 2 s . c o m*/ public class Main { public static void main(String[] args) throws Exception { Path path = Paths.get("C:/tutorial/Java/JavaFX", "Topic.txt"); //extract a single attribute with getAttribute try { long size = (Long) Files.getAttribute(path, "basic:size", java.nio.file.LinkOption.NOFOLLOW_LINKS); System.out.println("Size: " + size); } catch (IOException e) { System.err.println(e); } } }