Java examples for File Path IO:File Attribute
Obtaining a single attribute at a time using the getAttribute method
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void main(String[] args) { try {//ww w .j a va2 s . c o m Path path = FileSystems.getDefault().getPath("/home/docs/users.txt"); System.out.println(Files.getAttribute(path, "size")); } catch (IOException ex) { System.out.println("IOException"); } } }