Level 94 Level 96
Level 95

File Class


42 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
Java File class
represents the files and directory pathnames in an abstract manner.
File(File parent, String child)
This constructor creates a new File instance from a parent abstract pathname and a child pathname string.
File(String pathname)
This constructor creates a new File instance by converting the given pathname string into an abstract pathname.
File(String parent, String child)
This constructor creates a new File instance from a parent pathname string and a child pathname string.
File(URI uri)
This constructor creates a new File instance by converting the given file: URI into an abstract pathname.
public String getName()
Returns the name of the file or directory denoted by this abstract pathname.
public String getParent()
Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.
public File getParentFile()
Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.
public String getPath()
Converts this abstract pathname into a pathname string.
public boolean isAbsolute()
Tests whether this abstract pathname is absolute. Returns true if this abstract pathname is absolute, false otherwise
public String getAbsolutePath()
Returns the absolute pathname string of this abstract pathname.
public boolean canRead()
Tests whether the application can read the file denoted by this abstract pathname. Returns true if and only if the file specified by this abstract pathname exists and can be read by the application; false otherwise.
public boolean canWrite()
Tests whether the application can modify to the file denoted by this abstract pathname.
public boolean exists()
Tests whether the file or directory denoted by this abstract pathname exists. Returns true if and only if the file or directory denoted by this abstract pathname exists; false otherwise
public boolean isDirectory()
Tests whether the file denoted by this abstract pathname is a directory. Returns true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise.
public boolean isFile()
Tests whether the file denoted by this abstract pathname is a normal file. A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria.
public long lastModified()
Returns the time that the file denoted by this abstract pathname was last modified.
public long length()
Returns the length of the file denoted by this abstract pathname. the return value is unspecified if this pathname denotes a directory.
public boolean delete()
Deletes the file or directory denoted by this abstract pathname.
public void deleteOnExit()
Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.
public String[] list()
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
public File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
public File[] listFiles(FileFilter filter)
Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
public boolean mkdir()
Creates the directory named by this abstract pathname. Returns true if and only if the directory was created; false otherwise.
public boolean mkdirs()
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Returns true if and only if the directory was created, along with all necessary parent directories; false otherwise.
public boolean renameTo(File dest)
Renames the file denoted by this abstract pathname. Returns true if and only if the renaming succeeded; false otherwise.
public boolean setLastModified(long time)
Sets the last-modified time of the file or directory named by this abstract pathname. Returns true if and only if the operation succeeded; false otherwise.
public boolean setReadOnly()
Marks the file or directory named by this abstract pathname so that only read operations are allowed. Returns true if and only if the operation succeeded; false otherwise.
public int compareTo(File pathname)
Compares two abstract pathnames lexicographically.
public int compareTo(Object o)
Compares this abstract pathname to another object.
public boolean equals(Object obj)
Tests this abstract pathname for equality with the given object. Returns true if and only if the argument is not null and is an abstract pathname that denotes the same file or directory as this abstract pathname.
public String toString()
Returns the pathname string of this abstract pathname. This is just the string returned by the getPath() method.
FileReader Class
used for reading streams of characters.
FileReader(File file)
This constructor creates a new FileReader, given the File to read from.
FileReader(FileDescriptor fd)
This constructor creates a new FileReader, given the FileDescriptor to read from.
FileReader(String fileName)
This constructor creates a new FileReader, given the name of the file to read from.
public int read() throws IOException
Reads a single character. Returns an int, which represents the character read.
FileWriter Class
used for writing streams of characters.
FileWriter(File file)
This constructor creates a FileWriter object given a File object.
FileWriter(File file, boolean append)
This constructor creates a FileWriter object given a File object. with a boolean indicating whether or not to append the data written.
FileWriter(FileDescriptor fd)
This constructor creates a FileWriter object associated with the given file descriptor.
FileWriter(String fileName)
This constructor creates a FileWriter object, given a file name.