|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.io.File
This class represents a file name of the host file system. The file name can be relative or absolute. It must use the file name conventions of the host platform.
The intention is to provide an abstraction that deals with most of the system-dependent file name features such as the separator character, root, device name, etc. Not all features are currently fully implemented.
Note that whenever a file name or path is used it is assumed that the host's file name conventions are used.
Field Summary | |
static String |
pathSeparator
The system dependent path separator string. |
static char |
pathSeparatorChar
The system dependent path separator character. |
static String |
separator
The system dependent file separator String. |
static char |
separatorChar
The system dependent file separator character. |
Constructor Summary | |
File(File dir,
String name)
Creates a File object (given a directory File object). |
|
File(String path)
Creates a File object. |
|
File(String path,
String name)
Creates a File object from the specified directory. |
Method Summary | |
boolean |
canRead()
Returns a boolean indicating whether or not a readable file exists. |
boolean |
canWrite()
Returns a boolean indicating whether or not a writable file exists. |
boolean |
delete()
Deletes the specified file. |
boolean |
equals(Object obj)
Compares this object against the specified object. |
boolean |
exists()
Returns a boolean indicating whether or not a file exists. |
String |
getAbsolutePath()
Gets the absolute path of the file. |
String |
getName()
Gets the name of the file. |
String |
getParent()
Gets the name of the parent directory. |
String |
getPath()
Gets the path of the file. |
int |
hashCode()
Computes a hashcode for the file. |
boolean |
isAbsolute()
Returns a boolean indicating whether the file name is absolute. |
boolean |
isDirectory()
Returns a boolean indicating whether or not a directory file exists. |
boolean |
isFile()
Returns a boolean indicating whether or not a normal file exists. |
long |
lastModified()
Returns the last modification time. |
long |
length()
Returns the length of the file. |
String[] |
list()
Lists the files in a directory. |
String[] |
list(FilenameFilter filter)
Uses the specified filter to list files in a directory. |
boolean |
mkdir()
Creates a directory and returns a boolean indicating the success of the creation. |
boolean |
mkdirs()
Creates all directories in this path. |
boolean |
renameTo(File dest)
Renames a file and returns a boolean indicating whether or not this method was successful. |
String |
toString()
Returns a String object representing this file's path. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String separator
public static final char separatorChar
public static final String pathSeparator
public static final char pathSeparatorChar
Constructor Detail |
public File(String path)
path
- the file path
NullPointerException
- If the file path is equal to
null.public File(String path, String name)
path
- the directory pathname
- the file namepublic File(File dir, String name)
dir
- the directoryname
- the file nameMethod Detail |
public String getName()
public String getPath()
public String getAbsolutePath()
public String getParent()
public boolean exists()
public boolean canWrite()
public boolean canRead()
public boolean isFile()
public boolean isDirectory()
public boolean isAbsolute()
public long lastModified()
public long length()
public boolean mkdir()
public boolean renameTo(File dest)
dest
- the new file namepublic boolean mkdirs()
public String[] list()
public String[] list(FilenameFilter filter)
filter
- the filter used to select file names
FilenameFilter
public boolean delete()
public int hashCode()
hashCode
in class Object
Hashtable
public boolean equals(Object obj)
equals
in class Object
obj
- the object to compare with
Hashtable
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |