All Implemented Interfaces:
Serializable, Comparable<File>

  • Field Summary

    Fields

    The system-dependent path-separator character, represented as a string for convenience.

    static final char

    The system-dependent path-separator character.

    The system-dependent default name-separator character, represented as a string for convenience.

    static final char

    The system-dependent default name-separator character.

  • Constructor Summary

    Constructors

    Creates a new File instance from a parent abstract pathname and a child pathname string.

    Creates a new File instance by converting the given pathname string into an abstract pathname.

    Creates a new File instance from a parent pathname string and a child pathname string.

    Creates a new File instance by converting the given file: URI into an abstract pathname.

  • Method Summary

    boolean

    Tests whether the application can execute the file denoted by this abstract pathname.

    boolean

    canRead()

    Tests whether the application can read the file denoted by this abstract pathname.

    boolean

    canWrite()

    Tests whether the application can modify the file denoted by this abstract pathname.

    int

    Compares two abstract pathnames lexicographically.

    boolean

    Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.

    Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.

    Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.

    boolean

    delete()

    Deletes the file or directory denoted by this abstract pathname.

    void

    Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.

    boolean

    Tests this abstract pathname for equality with the given object.

    boolean

    exists()

    Tests whether the file or directory denoted by this abstract pathname exists.

    Returns the absolute form of this abstract pathname.

    Returns the absolute pathname string of this abstract pathname.

    Returns the canonical form of this abstract pathname.

    Returns the canonical pathname string of this abstract pathname.

    long

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

    getName()

    Returns the name of the file or directory denoted by this abstract pathname.

    getParent()

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

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

    getPath()

    Converts this abstract pathname into a pathname string.

    long

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

    long

    Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.

    int

    hashCode()

    Computes a hash code for this abstract pathname.

    boolean

    Tests whether this abstract pathname is absolute.

    boolean

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

    boolean

    isFile()

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

    boolean

    isHidden()

    Tests whether the file named by this abstract pathname is a hidden file.

    long

    Returns the time that the file denoted by this abstract pathname was last modified.

    long

    length()

    Returns the length of the file denoted by this abstract pathname.

    list()

    Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

    Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

    listFiles()

    Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

    Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

    Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

    listRoots()

    List the available filesystem roots.

    boolean

    mkdir()

    Creates the directory named by this abstract pathname.

    boolean

    mkdirs()

    Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

    boolean

    Renames the file denoted by this abstract pathname.

    boolean

    setExecutable(boolean executable)

    A convenience method to set the owner's execute permission for this abstract pathname.

    boolean

    setExecutable(boolean executable, boolean ownerOnly)

    Sets the owner's or everybody's execute permission for this abstract pathname.

    boolean

    setLastModified(long time)

    Sets the last-modified time of the file or directory named by this abstract pathname.

    boolean

    setReadable(boolean readable)

    A convenience method to set the owner's read permission for this abstract pathname.

    boolean

    setReadable(boolean readable, boolean ownerOnly)

    Sets the owner's or everybody's read permission for this abstract pathname.

    boolean

    Marks the file or directory named by this abstract pathname so that only read operations are allowed.

    boolean

    setWritable(boolean writable)

    A convenience method to set the owner's write permission for this abstract pathname.

    boolean

    setWritable(boolean writable, boolean ownerOnly)

    Sets the owner's or everybody's write permission for this abstract pathname.

    toPath()

    toString()

    Returns the pathname string of this abstract pathname.

    toURI()

    Constructs a file: URI that represents this abstract pathname.

    toURL()

  • Field Details

    • separatorChar

    • separator

    • pathSeparatorChar

    • pathSeparator

  • Constructor Details

    • File

    • File

    • File

    • File

  • Method Details

    • getName

    • getParent

    • getParentFile

    • getPath

    • isAbsolute

    • getAbsolutePath

    • getAbsoluteFile

    • getCanonicalPath

    • getCanonicalFile

    • toURL

    • toURI

    • canRead

    • canWrite

    • exists

    • isDirectory

    • isFile

    • isHidden

    • lastModified

    • length

    • createNewFile

    • delete

    • deleteOnExit

    • list

    • list

    • listFiles

    • listFiles

    • listFiles

    • mkdir

    • mkdirs

    • renameTo

    • setLastModified

    • setReadOnly

    • setWritable

    • setWritable

    • setReadable

    • setReadable

    • setExecutable

    • setExecutable

    • canExecute

    • listRoots

    • getTotalSpace

    • getFreeSpace

    • getUsableSpace

    • createTempFile

    • createTempFile

    • compareTo

    • equals

    • hashCode

    • toString

    • toPath