Java Reference
In-Depth Information
is lexicographically less than, equal to, or greater than the pathname
of the argument
File
. The
compareTo
method has two overloaded forms:
one takes a
File
argument and the other takes an
Object
argument and
so implements the
Comparable
interface.
Several boolean tests return information about the underlying file:
•
exists
returns
TRue
if the file exists in the file system.
•
canRead
returns
true
if a file exists and can be read.
•
canWrite
returns
true
if the file exists and can be written.
•
isFile
returns
true
if the file is not a directory or other special
type of file.
•
isDirectory
returns
TRue
if the file is a directory.
•
isAbsolute
returns
true
if the path is an absolute pathname.
•
isHidden
returns
TRue
if the path is one normally hidden from users
on the underlying system.
All the methods that inspect or modify the actual file system are security
checked and can throw
SecurityException
if you don't have permission to
perform the operation. Methods that ask for the filename itself are not
security checked.
File
objects have many other methods for manipulating files and direct-
ories. There are methods to inspect and manipulate the current file:
public long
lastModified()
Returns a
long
value representing the time the file was last
modified or zero if the file does not exist.
public long
length()