O'Reilly logo

Core Java® Volume II—Advanced Features, Ninth Edition by Gary Cornell, Cay S. Horstmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

1.6.5. Getting File Information

The following static methods return a boolean value to check a property of a path:

exists

isHidden

isReadable, isWritable, isExecutable

isRegularFile, isDirectory, isSymbolicLink

The size method returns the number of bytes in a file.

long fileSize = Files.size(path);

The getOwner method returns the owner of the file, as an instance of java.nio.file.attribute.UserPrincipal.

All file systems report a set of basic attributes, encapsulated by the BasicFileAttributes interface, which partially overlaps with that information. The basic file attributes are

• The times at which the file was created, last accessed, and last modified, as instances of the class java.nio.file.attribute.FileTime

• Whether the file is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required