The methods of the java.io.Writer
class are
deliberately similar to the methods of the
java.io.OutputStream
class. However rather than
working with bytes, they work with chars.
The basic write()
method writes a single two-byte
character with a value between 0 and 65535. The value is taken
from the two low-order bytes of the argument c
.
public void write(int c) throws IOException
You can also write an array of characters, a sub-array of characters, a String, or a substring.
public void write(char[] text) throws IOException
public abstract void write(char[] text, int offset, int length) throws IOException
public void write(String s) throws IOException
public void write(String s, int offset, int length) throws IOException
Like output streams, writers may be buffered. To force the write
to take place, call flush()
:
public abstract void flush() throws IOException
Finally the close()
method closes the
Writer
and releases any resources associated with
it.
public abstract void close() throws IOException