| java.lang.Object sun.io.FileIO
All known Subclasses: sun.io.FileFileIO,
FileIO | abstract public class FileIO implements Serializable(Code) | | Instances of this class represent the name of a file or directory
on the host file system. A file is specified by a pathname, which
can either be an absolute pathname or a pathname relative to the
current working directory. The pathname must follow the naming
conventions of the host platform.
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.
version: 1.10, 02/08/19 author: Saul Wold since: JDK1.0 |
Field Summary | |
protected String | path The path of the file. | final public static String | pathSeparator The system-dependent path separator string. | final public static char | pathSeparatorChar The system-dependent path separator character. | final public static String | separator The system-dependent path separator character. | final public static char | separatorChar The system-dependent path separator string. |
Constructor Summary | |
public | FileIO() | protected | FileIO(String path) Creates a File instance that represents the file
whose pathname is the given path argument. | protected | FileIO(String path, String name) Creates a File instance whose pathname is the
pathname of the specified directory, followed by the separator
character, followed by the name argument. | protected | FileIO(FileIO dir, String name) Creates a File instance that represents the file
with the specified name in the specified directory. |
Method Summary | |
abstract public boolean | canRead() Tests if the application can read from the specified file. | abstract public boolean | canWrite() Tests if the application can write to this file. | abstract String | canonPath(String path) | abstract boolean | delete() Deletes the file specified by this object. | public boolean | equals(Object obj) Compares this object against the specified object.
Returns 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. | abstract public boolean | exists() Tests if this File exists. | public String | getAbsolutePath() Returns the absolute pathname of the file represented by this object.
If this object represents an absolute pathname, then return the
pathname. | public String | getCanonicalPath() Returns the canonical form of this 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. | abstract public InputStream | getInputStream() | public String | getName() Returns the name of the file represented by this object. | abstract public OutputStream | getOutputStream() | public String | getParent() Returns the parent part of the pathname of this File
object, or null if the name has no parent part. | public String | getPath() Returns the pathname of the file represented by this object. | public int | hashCode() Computes a hashcode for the file. | abstract public boolean | isAbsolute() Tests if the file represented by this File object is an
absolute pathname. | abstract public boolean | isDirectory() Tests if the file represented by this File
object is a directory. | abstract public boolean | isFile() Tests if the file represented by this File
object is a "normal" file. | abstract public long | lastModified() Returns the time that the file represented by this
File object was last modified. | abstract public long | length() Returns the length of the file represented by this
File object. | abstract public String[] | list() Returns a list of the files in the directory specified by this
File object. | abstract public boolean | mkdir() Creates a directory whose pathname is specified by this
File object. | public boolean | mkdirs() Creates a directory whose pathname is specified by this
File object, including any necessary parent directories. | public String | toString() Returns a string representation of this object. |
path | protected String path(Code) | | The path of the file. The host's file separator is used.
|
pathSeparatorChar | final public static char pathSeparatorChar(Code) | | The system-dependent path separator character. This field is
initialized to contain the first character of
File.pathSeparator . This character is
often used to separate filenames in a sequence of files given as a
"path list".
See Also: java.io.File.pathSeparator(java.lang.String) since: JDK1.0 |
separatorChar | final public static char separatorChar(Code) | | The system-dependent path separator string. This field is
initialized to contain the first character of the value of
File.separator . This character
separates the directory and file components in a filename.
See Also: java.io.File.separator(java.lang.String) since: JDK1.0 |
FileIO | protected FileIO(String path)(Code) | | Creates a File instance that represents the file
whose pathname is the given path argument.
Parameters: path - the file pathname. exception: NullPointerException - if the file path is equal tonull . See Also: java.io.File.getPath since: JDK1.0 |
FileIO | protected FileIO(String path, String name)(Code) | | Creates a File instance whose pathname is the
pathname of the specified directory, followed by the separator
character, followed by the name argument.
Parameters: path - the directory pathname. Parameters: name - the file pathname. See Also: java.io.File.getPath See Also: java.io.File.separator since: JDK1.0 |
FileIO | protected FileIO(FileIO dir, String name)(Code) | | Creates a 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.
Parameters: dir - the directory. Parameters: name - the file pathname. See Also: java.io.File.getPath See Also: java.io.File.separator since: JDK1.0 |
canRead | abstract public boolean canRead()(Code) | | Tests if the application can read from the specified file.
true if the file specified by this object existsand the application can read the file;false otherwise. exception: SecurityException - if a security manager exists, itscheckRead method is called with the pathnameof this File to see if the application isallowed read access to the file. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkRead(java.lang.String) since: JDK1.0 |
canWrite | abstract public boolean canWrite()(Code) | | Tests if the application can write to this file.
true if the application is allowed to write toa file whose name is specified by this object;false otherwise. exception: SecurityException - if a security manager exists, itscheckWrite method is called with the pathnameof this File to see if the application isallowed write access to the file. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkWrite(java.lang.String) since: JDK1.0 |
delete | abstract boolean delete()(Code) | | Deletes the file specified by this object. If the target
file to be deleted is a directory, it must be empty for deletion
to succeed.
true if the file is successfully deleted;false otherwise. exception: SecurityException - if a security manager exists, itscheckDelete method is called with thepathname of this File to see if theapplication is allowed to delete the file. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkDelete(java.lang.String) since: JDK1.0 |
equals | public boolean equals(Object obj)(Code) | | Compares this object against the specified object.
Returns 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.
Parameters: obj - the object to compare with. true if the objects are the same;false otherwise. since: JDK1.0 |
getAbsolutePath | public String getAbsolutePath()(Code) | | Returns the absolute pathname of the file represented by this object.
If this object represents an absolute pathname, then return the
pathname. Otherwise, return a pathname that is a concatenation of
the current user directory, the separator character, and the
pathname of this file object.
The system property user.dir contains the current
user directory.
a system-dependent absolute pathname for this File . See Also: java.io.File.getPath See Also: java.io.File.isAbsolute See Also: java.lang.System.getProperty(java.lang.String) since: JDK1.0 |
getCanonicalPath | public String getCanonicalPath() throws IOException(Code) | | Returns the canonical form of this 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.
exception: IOException - If an I/O error occurs, which is possible becausethe construction of the canonical path may require filesystem queries. since: JDK1.1 |
getName | public String getName()(Code) | | Returns the name of the file represented by this object. The name
is everything in the pathame after the last occurrence of the
separator character.
the name of the file (without any directory components)represented by this File object. See Also: java.io.File.getPath See Also: java.io.File.separator since: JDK1.0 |
getParent | public String getParent()(Code) | | Returns the parent part of the pathname of this 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.
See Also: java.io.File.getPath See Also: java.io.File.getCanonicalPath See Also: java.io.File.separator since: JDK1.0 |
getPath | public String getPath()(Code) | | Returns the pathname of the file represented by this object.
the pathname represented by this File object. since: JDK1.0 |
hashCode | public int hashCode()(Code) | | Computes a hashcode for the file.
a hash code value for this File object. since: JDK1.0 |
isAbsolute | abstract public boolean isAbsolute()(Code) | | Tests if the file represented by this 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 theFile object is an absolute pathname;false otherwise. See Also: java.io.File.getPath See Also: java.io.File.separator since: JDK1.0 |
isFile | abstract public boolean isFile()(Code) | | Tests if the file represented by this 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 objectexists and is a "normal" file; false otherwise. exception: SecurityException - If a security manager exists, itscheckRead method is called with the pathnameof this File to see if the application isallowed read access to the file. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkRead(java.lang.String) since: JDK1.0 |
lastModified | abstract public long lastModified()(Code) | | Returns the time that the file represented by this
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.
the time the file specified by this object was last modified,or 0L if the specified file does not exist. exception: SecurityException - if a security manager exists, itscheckRead method is called with the pathnameof this File to see if the application isallowed read access to the file. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkRead(java.lang.String) since: JDK1.0 |
length | abstract public long length()(Code) | | Returns the length of the file represented by this
File object.
the length, in bytes, of the file specified by this object,or 0L if the specified file does not exist. exception: SecurityException - if a security manager exists, itscheckRead method is called with the pathnameof this File to see if the application isallowed read access to the file. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkRead(java.lang.String) since: JDK1.0 |
list | abstract public String[] list()(Code) | | Returns a list of the files in the directory specified by this
File object.
an array of file names in the specified directory.This list does not include the current directory or theparent directory (". " and ".. "on Unix systems). exception: SecurityException - If a security manager exists, itscheckRead method is called with the pathnameof this File to see if the application isallowed read access to the file. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkRead(java.lang.String) since: JDK1.0 |
mkdirs | public boolean mkdirs()(Code) | | Creates a directory whose pathname is specified by this
File object, including any necessary parent directories.
true if the directory (or directories) could becreated; false otherwise. exception: SecurityException - if a security manager exists, itscheckWrite method is called with the pathnameof each of the directories that is to be created, beforeany of the directories are created. See Also: java.io.File.getPath See Also: java.lang.SecurityManager.checkWrite(java.lang.String) since: JDK1.0 |
toString | public String toString()(Code) | | Returns a string representation of this object.
a string giving the pathname of this object. See Also: java.io.File.getPath since: JDK1.0 |
|
|