Mega Code Archive

 
Categories / Java Tutorial / File
 

Writer

The abstract class 'Writer' defines a stream used for writing characters. OutputStreamWriter translates the characters into byte streams using a given character set. FileWriter is a child class of OutputStreamWriter that provides a convenient way to write characters to a file. When using FileWriter you are forced to output characters using the computer's encoding. A better alternative to FileWriter is PrintWriter. Writer deals with characters instead of bytes. Writer class has three write method overloads: public void write (int b) public void write (char[] text) public void write (char[] text, int offset, int length) public void write (String text) public void write (String text, int offset, int length)