Java Reference
In-Depth Information
public
String getName()
Returns the last name in the abstract pathname (that is, the simple fi le name). Returns the empty
string if the abstract pathname is the empty string.
public
String getPath()
Returns the abstract pathname as a
String
value.
public boolean
isDirectory()
Returns
true
if a directory (folder) exists that is named by the abstract pathname; otherwise
returns
false
.
public boolean
isFile()
Returns
true
if a fi le exists that is named by the abstract pathname and the fi le is a normal fi le;
otherwise returns
false
. The meaning of
normal
is system dependent. Any fi le created by a
Java program is guaranteed to be normal.
public long
length()
Returns the length in bytes of the fi le named by the abstract pathname. If the fi le does not exist
or the abstract pathname names a directory, then the value returned is not specifi ed and may
be anything.
public boolean
mkdir()
Makes a directory named by the abstract pathname. Will not create parent directories. See
mkdirs
. Returns
true
if successful; otherwise returns
false
.
public boolean
mkdirs()
Makes a directory named by the abstract pathname. Will create any necessary but nonexistent
parent directories. Returns
true
if successful; otherwise returns
false
. Note that if it fails, then
some of the parent directories may have been created.
public boolean
renameTo(File newName)
Renames the fi le represented by the abstract pathname to
newName
. Returns
true
if
successful; otherwise returns
false
.
newName
can be a relative or absolute pathname. This may
require moving the fi le. Whether or not the fi le can be moved is system dependent.
Throws:
NullPointerException
if parameter
newName
is
null
.
public boolean
setReadOnly()
Sets the fi le represented by the abstract pathname to be read only. Returns
true
if successful;
otherwise returns
false
.