Java java.io File fields, constructors, methods, implement or subclass

Example usage for Java java.io File fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.io File.

The text is from its open source code.

Subclass

java.io.File has subclasses.
Click this link to see all its subclasses.

Implementation

java.io.File has the following implementations.
Click this link to see all its implementation.

Field

Stringpath
This abstract pathname's normalized pathname string.
charseparatorChar
The system-dependent default name-separator character.
Stringseparator
The system-dependent default name-separator character, represented as a string for convenience.
charpathSeparatorChar
The system-dependent path-separator character.
StringpathSeparator
The system-dependent path-separator character, represented as a string for convenience.

Constructor

File(String pathname)
Creates a new File instance by converting the given pathname string into an abstract pathname.
File(URI uri)
Creates a new File instance by converting the given file: URI into an abstract pathname.
File(String pathname, int prefixLength)
Internal constructor for already-normalized pathname strings.
File(String child, File parent)
Internal constructor for already-normalized pathname strings.
File(String parent, String child)
Creates a new File instance from a parent pathname string and a child pathname string.
File(File parent, String child)
Creates a new File instance from a parent abstract pathname and a child pathname string.

Method

booleancanExecute()
Tests 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.
Objectclone()
Creates and returns a copy of this object.
intcompareTo(File pathname)
Compares two abstract pathnames lexicographically.
booleancreateNewFile()
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
FilecreateTempFile(String prefix, String suffix)
Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.
FilecreateTempFile(String prefix, String suffix, File directory)

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.
voiddeleteOnExit()
Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
booleanequals(Object obj)
Tests this abstract pathname for equality with the given object.
booleanexists()
Tests whether the file or directory denoted by this abstract pathname exists.
FilegetAbsoluteFile()
Returns the absolute form of this abstract pathname.
StringgetAbsolutePath()
Returns the absolute pathname string of this abstract pathname.
FilegetCanonicalFile()
Returns the canonical form of this abstract pathname.
StringgetCanonicalPath()
Returns the canonical pathname string of this abstract pathname.
ClassgetClass()
Returns the runtime class of this Object .
longgetFreeSpace()
Returns the number of unallocated bytes in the partition named by this abstract path name.
StringgetName()
Returns the name of the file or directory denoted by this abstract pathname.
StringgetParent()
Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
FilegetParentFile()
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
StringgetPath()
Converts this abstract pathname into a pathname string.
longgetTotalSpace()
Returns the size of the partition named by this abstract pathname.
longgetUsableSpace()
Returns 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.
booleanisAbsolute()
Tests whether this abstract pathname is absolute.
booleanisDirectory()
Tests 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.
longlastModified()
Returns 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.
String[]list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
String[]list(FilenameFilter filter)
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
File[]listFiles(FilenameFilter 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.
File[]listFiles(FileFilter 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.
File[]listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
File[]listRoots()
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.
booleanrenameTo(File dest)
Renames 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.
booleansetReadOnly()
Marks 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.
PathtoPath()
Returns a Path java.nio.file.Path object constructed from this abstract path.
StringtoString()
Returns the pathname string of this abstract pathname.
URItoURI()
Constructs a file: URI that represents this abstract pathname.
URLtoURL()
Converts this abstract pathname into a file: URL.
voidwait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.