The java.io.OutputStreamWriter class connects byte streams and character streams: It writes bytes onto the underlying output stream after translating characters according to a specified character encoding. The encoding can be set in the constructor, or you can accept the platform's default encoding.

 public OutputStreamWriter(OutputStream out, String enc) 
  throws UnsupportedEncodingException
 public OutputStreamWriter(OutputStream out)

For example, if you wanted to write a file encoded in the Macintosh Symbol font, you might do this:

FileOutputStream fout = new FileOutputStream("symbol.txt");
OutputStreamWriter osw = new OutputStreamWriter(fout, "MacSymbol");

The other methods just override methods from java.io.Writer, but behave identically from the perspective of the programmer.

 public void write(int c) throws IOException
 public void write(char c[], int offset, int length) throws IOException
 public void write(String s, int offset, int length) throws IOException
 public void flush() throws IOException
 public void close() throws IOException

Copyright 2000 Elliotte Rusty Harold
Last Modified January 29, 2000