java.io.FileWriter
java.io.OutputStreamWriter
None
None
New as of JDK 1.1
The FileWriter class represents a character stream that writes data to a file. It is a subclass of OutputStreamWriter that uses a default buffer size (8192 bytes) to write bytes to a file and the default character encoding scheme to convert characters to bytes. If you need to specify the character encoding or the buffer size, wrap an OutputStreamWriter around a FileOutputStream.
The file can be specified using a FileDescriptor, a File object, or a String that represents a pathname. All of the constructors can throw a SecurityException if the application does not have permission to write to the specified file.
FileWriter provides a low-level interface for writing character data to a file. You should think about wrapping a FileWriter with a BufferedWriter to increase writing efficiency.
If you need to write binary data to a file, you should use a FileOutputStream wrapped by a DataOutputStream or a PrintStream instead.
public class java.io.FileWriter extends java.io.OutputStreamWriter { // Constructors public FileWriter(String fileName); public FileWriter(String fileName, boolean append); public FileWriter(File file); public FileWriter(FileDescriptor fd); }
The pathname of the file to use as output.
If the named file cannot be found.
If the application does not have permission to write to the named file.
This constructor creates a FileWriter that sends its output to the file named by the specified String.
public FileWriter(String fileName, boolean append) throws IOException
The pathname of the file to use as output.
Specifies whether or not data is appended to the output stream.
If the named file cannot be found.
If the application does not have permission to write to the named file.
This constructor creates a FileWriter that sends its output to the named file. If append is true, the stream is positioned at the end of the file, and data is appended to the end of the file. Otherwise, if append is false, the stream is positioned at the beginning of the file, and any previous data is overwritten.
The File to use as output.
If the named file cannot be found.
If the application does not have permission to write to the named file.
This constructor creates a FileWriter that sends its output to the file represented by the specified File object.
The FileDescriptor of the file to use as output.
If the application does not have permission to write to the specified file.
If FileDescriptor is null.
This constructor creates a FileWriter that sends its output to the file identified by the given FileDescriptor.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
close() |
OutputStreamWriter |
equals(Object) |
Object |
finalize() |
Object |
flush() |
OutputStreamWriter |
getClass() |
Object |
getEncoding() |
OutputStreamWriter |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
write(int) |
OutputStreamWriter |
write(char[]) |
Writer |
write(char[], int, int) |
OutputStreamWriter |
write(String) |
Writer |
write(String, int, int) |
OutputStreamWriter |
BufferedWriter, DataOutputStream, File, FileDescriptor, FileNotFoundException, FileOutputStream, IOException, NullPointerException, OutputStreamWriter, SecurityException, Writer
This HTML Help has been published using the chm2web software. |