File (Java SE 25 & JDK 25)
- All Implemented Interfaces:
Serializable, Comparable<File>
-
Field Summary
Fields
The system-dependent path-separator character, represented as a string for convenience.
static final charThe system-dependent path-separator character.
The system-dependent default name-separator character, represented as a string for convenience.
static final charThe system-dependent default name-separator character.
-
Constructor Summary
Constructors
Creates a new
Fileinstance from a parent abstract pathname and a child pathname string.Creates a new
Fileinstance by converting the given pathname string into an abstract pathname.Creates a new
Fileinstance from a parent pathname string and a child pathname string.Creates a new
Fileinstance by converting the givenfile:URI into an abstract pathname. -
Method Summary
booleanTests whether the application can execute the file denoted by this abstract pathname.
booleancanRead()Tests whether the application can read the file denoted by this abstract pathname.
booleancanWrite()Tests whether the application can modify the file denoted by this abstract pathname.
intCompares two abstract pathnames lexicographically.
booleanAtomically 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.
booleandelete()Deletes the file or directory denoted by this abstract pathname.
voidRequests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
booleanTests this abstract pathname for equality with the given object.
booleanexists()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.
longReturns 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.
Returns the pathname string of this abstract pathname's parent, or
nullif this pathname does not name a parent directory.Returns the abstract pathname of this abstract pathname's parent, or
nullif this pathname does not name a parent directory.getPath()Converts this abstract pathname into a pathname string.
longReturns the size of the partition named by this abstract pathname.
longReturns the number of bytes available to this virtual machine on the partition named by this abstract pathname.
inthashCode()Computes a hash code for this abstract pathname.
booleanTests whether this abstract pathname is absolute.
booleanTests whether the file denoted by this abstract pathname is a directory.
booleanisFile()Tests whether the file denoted by this abstract pathname is a normal file.
booleanisHidden()Tests whether the file named by this abstract pathname is a hidden file.
longReturns the time that the file denoted by this abstract pathname was last modified.
longlength()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.
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.
List the available filesystem roots.
booleanmkdir()Creates the directory named by this abstract pathname.
booleanmkdirs()Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.
booleanRenames the file denoted by this abstract pathname.
booleansetExecutable(boolean executable) A convenience method to set the owner's execute permission for this abstract pathname.
booleansetExecutable(boolean executable, boolean ownerOnly) Sets the owner's or everybody's execute permission for this abstract pathname.
booleansetLastModified(long time) Sets the last-modified time of the file or directory named by this abstract pathname.
booleansetReadable(boolean readable) A convenience method to set the owner's read permission for this abstract pathname.
booleansetReadable(boolean readable, boolean ownerOnly) Sets the owner's or everybody's read permission for this abstract pathname.
booleanMarks the file or directory named by this abstract pathname so that only read operations are allowed.
booleansetWritable(boolean writable) A convenience method to set the owner's write permission for this abstract pathname.
booleansetWritable(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
-