Constructors

Methods

  • Returns the absolute form of this abstract pathname. Equivalent to new File(this.#getAbsolutePath).

    Returns File

    The absolute abstract pathname denoting the same file or directory as this abstract pathname

    Throws

    SecurityException If a required system property value cannot be accessed.

    Since

    1.2

  • Returns the absolute pathname string of this abstract pathname.

    If this abstract pathname is already absolute, then the pathname string is simply returned as if by the #getPath method. If this abstract pathname is the empty abstract pathname then the pathname string of the current user directory, which is named by the system property user.dir, is returned. Otherwise this pathname is resolved in a system-dependent way. On UNIX systems, a relative pathname is made absolute by resolving it against the current user directory. On Microsoft Windows systems, a relative pathname is made absolute by resolving it against the current directory of the drive named by the pathname, if any; if not, it is resolved against the current user directory.

    Returns string

    The absolute pathname string denoting the same file or directory as this abstract pathname

    Throws

    SecurityException If a required system property value cannot be accessed.

    See

    java.io.File#isAbsolute()

  • Returns the canonical form of this abstract pathname. Equivalent to new File(this.#getCanonicalPath).

    Returns File

    The canonical pathname string denoting the same file or directory as this abstract pathname

    Throws

    IOException If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries

    Throws

    SecurityException If a required system property value cannot be accessed, or if a security manager exists and its java.lang.SecurityManager#checkRead method denies read access to the file

    Since

    1.2

    See

    Path#toRealPath

  • Returns the canonical pathname string of this abstract pathname.

    A canonical pathname is both absolute and unique. The precise definition of canonical form is system-dependent. This method first converts this pathname to absolute form if necessary, as if by invoking the #getAbsolutePath method, and then maps it to its unique form in a system-dependent way. This typically involves removing redundant names such as "." and ".." from the pathname, resolving symbolic links (on UNIX platforms), and converting drive letters to a standard case (on Microsoft Windows platforms).

    Every pathname that denotes an existing file or directory has a unique canonical form. Every pathname that denotes a nonexistent file or directory also has a unique canonical form. The canonical form of the pathname of a nonexistent file or directory may be different from the canonical form of the same pathname after the file or directory is created. Similarly, the canonical form of the pathname of an existing file or directory may be different from the canonical form of the same pathname after the file or directory is deleted.

    Returns string

    The canonical pathname string denoting the same file or directory as this abstract pathname

    Throws

    IOException If an I/O error occurs, which is possible because the construction of the canonical pathname may require filesystem queries

    Throws

    SecurityException If a required system property value cannot be accessed, or if a security manager exists and its java.lang.SecurityManager#checkRead method denies read access to the file

    Since

    1.1

    See

    Path#toRealPath

  • Returns the number of unallocated bytes in the partition named by this abstract path name.

    The returned number of unallocated bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after this call. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine. This method makes no guarantee that write operations to this file system will succeed.

    Returns number

    The number of unallocated bytes on the partition or 0L if the abstract pathname does not name a partition. This value will be less than or equal to the total file system size returned by #getTotalSpace.

    Throws

    SecurityException If a security manager has been installed and it denies RuntimePermission("getFileSystemAttributes") or its SecurityManager#checkRead(String) method denies read access to the file named by this abstract pathname

    Since

    1.6

  • Returns the name of the file or directory denoted by this abstract pathname. This is just the last name in the pathname's name sequence. If the pathname's name sequence is empty, then the empty string is returned.

    Returns string

    The name of the file or directory denoted by this abstract pathname, or the empty string if this pathname's name sequence is empty

  • Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.

    The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.

    Returns string

    The pathname string of the parent directory named by this abstract pathname, or null if this pathname does not name a parent

  • Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.

    The parent of an abstract pathname consists of the pathname's prefix, if any, and each name in the pathname's name sequence except for the last. If the name sequence is empty then the pathname does not name a parent directory.

    Returns File

    The abstract pathname of the parent directory named by this abstract pathname, or null if this pathname does not name a parent

    Since

    1.2

  • Converts this abstract pathname into a pathname string. The resulting string uses the #separator default name-separator character to separate the names in the name sequence.

    Returns string

    The string form of this abstract pathname

  • Returns the size of the partition named by this abstract pathname.

    Returns number

    The size, in bytes, of the partition or 0L if this abstract pathname does not name a partition

    Throws

    SecurityException If a security manager has been installed and it denies RuntimePermission("getFileSystemAttributes") or its SecurityManager#checkRead(String) method denies read access to the file named by this abstract pathname

    Since

    1.6

  • Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname. When possible, this method checks for write permissions and other operating system restrictions and will therefore usually provide a more accurate estimate of how much new data can actually be written than #getFreeSpace.

    The returned number of available bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after this call. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine. This method makes no guarantee that write operations to this file system will succeed.

    Returns number

    The number of available bytes on the partition or 0L if the abstract pathname does not name a partition. On systems where this information is not available, this method will be equivalent to a call to #getFreeSpace.

    Throws

    SecurityException If a security manager has been installed and it denies RuntimePermission("getFileSystemAttributes") or its SecurityManager#checkRead(String) method denies read access to the file named by this abstract pathname

    Since

    1.6

  • Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\", or if its prefix is "\\".

    Returns boolean

    true if this abstract pathname is absolute, false otherwise

  • Tests whether the file denoted by this abstract pathname is a directory.

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

    Returns boolean

    true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise

    Throws

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

  • Tests whether the file denoted by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

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

    Returns boolean

    true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise

    Throws

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

  • Tests whether the file named by this abstract pathname is a hidden file. The exact definition of hidden is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.'). On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the filesystem.

    Returns boolean

    true if and only if the file denoted by this abstract pathname is hidden according to the conventions of the underlying platform

    Throws

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

    Since

    1.2