All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.io.File
The File class is intended to provide an abstraction that deals with most of the machine dependent complexities of files and pathnames in a machine-independent fashion.
Note that whenever a filename or path is used it is assumed that the host's file naming conventions are used.
File instance that represents the file with the specified name in the specified directory. File instance that represents the file whose pathname is the given path argument. File instance whose pathname is the pathname of the specified directory, followed by the separator character, followed by the name argument. File exists. File object's pathname. File object, or null if the name has no parent part. File object is an absolute pathname. File object is a directory. File object is a "normal" file. File object was last modified. File object. File object. File that satisfy the specified filter. File object. File object, including any necessary parent directories. File object to have the pathname given by the File argument. public static final String separator
file.separator.public static final char separatorChar
file.separator. This character separates the directory and file components in a filename.public static final String pathSeparator
path.separator.public static final char pathSeparatorChar
path.separator. This character is often used to separate filenames in a sequence of files given as a "path list".public File(String path)
File instance that represents the file whose pathname is the given path argument. null. public File(String path, String name)
File instance whose pathname is the pathname of the specified directory, followed by the separator character, followed by the name argument. public File(File dir, String name)
File instance that represents the file with the specified name in the specified directory. If the directory argument is null, the resulting File instance represents a file in the (system-dependent) current directory whose pathname is the name argument. Otherwise, the File instance represents a file whose pathname is the pathname of the directory, followed by the separator character, followed by the name argument.
public String getName()
File object. public String getPath()
File object. public String getAbsolutePath()
The system property user.dir contains the current user directory.
File. public String getCanonicalPath() throws IOException
File object's pathname. The precise definition of canonical form is system-dependent, but it usually specifies an absolute pathname in which all relative references and references to the current user directory have been completely resolved. The canonical form of a pathname of a nonexistent file may not be defined. public String getParent()
File object, or null if the name has no parent part. The parent part is generally everything leading up to the last occurrence of the separator character, although the precise definition is system dependent. On UNIX, for example, the parent part of "/usr/lib" is "/usr", whose parent part is "/", which in turn has no parent. On Windows platforms, the parent part of "c:\java" is "c:\", which in turn has no parent. public boolean exists()
File exists. true if the file specified by this object exists; false otherwise. checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public boolean canWrite()
true if the application is allowed to write to a file whose name is specified by this object; false otherwise. checkWrite method is called with the pathname of this File to see if the application is allowed write access to the file. public boolean canRead()
true if the file specified by this object exists and the application can read the file; false otherwise. checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public boolean isFile()
File object is a "normal" file. A file is "normal" if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.
true if the file specified by this object exists and is a "normal" file; false otherwise. checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public boolean isDirectory()
File object is a directory. true if this File exists and is a directory; false otherwise. checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public native boolean isAbsolute()
File object is an absolute pathname. The definition of an absolute pathname is system dependent. For example, on UNIX, a pathname is absolute if its first character is the separator character. On Windows platforms, a pathname is absolute if its first character is an ASCII '\' or '/', or if it begins with a letter followed by a colon. true if the pathname indicated by the File object is an absolute pathname; false otherwise. public long lastModified()
File object was last modified. The return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.
0L if the specified file does not exist. checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public long length()
File object. 0L if the specified file does not exist. checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public boolean mkdir()
File object. true if the directory could be created; false otherwise. checkWrite method is called with the pathname of this File to see if the application is allowed write access to the file. public boolean renameTo(File dest)
File object to have the pathname given by the File argument. true if the renaming succeeds; false otherwise. checkWrite method is called both with the pathname of this file object and with the pathname of the destination target object to see if the application is allowed to write to both files. public boolean mkdirs()
File object, including any necessary parent directories. true if the directory (or directories) could be created; false otherwise. checkWrite method is called with the pathname of each of the directories that is to be created, before any of the directories are created. public String[] list()
File object. ." and ".." on Unix systems). checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public String[] list(FilenameFilter filter)
File that satisfy the specified filter. ." and ".." on Unix systems). checkRead method is called with the pathname of this File to see if the application is allowed read access to the file. public boolean delete()
true if the file is successfully deleted; false otherwise. checkDelete method is called with the pathname of this File to see if the application is allowed to delete the file. public int hashCode()
File object. public boolean equals(Object obj)
true if and only if the argument is not null and is a File object whose pathname is equal to the pathname of this object. true if the objects are the same; false otherwise. public String toString()
All Packages Class Hierarchy This Package Previous Next Index