public long length ()

Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.

Where it is required to distinguish an I/O exception from the case that 0L is returned, or where several attributes of the same file are required at the same time, then the java.nio.file.Files.readAttributes(Path,Class,LinkOption[]) method may be used.

Returns:  The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist. Some operating systems may return 0L for pathnames denoting system-dependent entities such as devices or pipes.

Exceptions:
SecurityException     If a security manager exists and its java.lang.SecurityManager.checkRead(java.lang.String) method denies read access to the file