java.io
Class OutputStreamWriter

java.lang.Object
  |
  +--java.io.Writer
        |
        +--java.io.OutputStreamWriter
Direct Known Subclasses:
FileWriter

public class OutputStreamWriter
extends Writer

Untamed:


Field Summary
private  sun.nio.cs.StreamEncoder se
           
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
OutputStreamWriter(OutputStream out)
          Enabled: Create an OutputStreamWriter that uses the default character encoding.
OutputStreamWriter(OutputStream out, java.nio.charset.Charset cs)
          Enabled: Create an OutputStreamWriter that uses the given charset.
OutputStreamWriter(OutputStream out, java.nio.charset.CharsetEncoder enc)
          Enabled: Create an OutputStreamWriter that uses the given charset encoder.
OutputStreamWriter(OutputStream out, String charsetName)
          Enabled: Create an OutputStreamWriter that uses the named charset.
 
Method Summary
 void close()
          Enabled: Close the stream.
 void flush()
          Enabled: Flush the stream.
(package private)  void flushBuffer()
          Flush the output buffer to the underlying byte stream, without flushing the byte stream itself.
 String getEncoding()
          Enabled: Return the name of the character encoding being used by this stream.
 void write(char[] cbuf, int off, int len)
          Enabled: Write a portion of an array of characters.
 void write(int c)
          Enabled: Write a single character.
 void write(String str, int off, int len)
          Enabled: Write a portion of a string.
 
Methods inherited from class java.io.Writer
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

se

private final sun.nio.cs.StreamEncoder se
Constructor Detail

OutputStreamWriter

public OutputStreamWriter(OutputStream out,
                          String charsetName)
                   throws UnsupportedEncodingException
Enabled: Create an OutputStreamWriter that uses the named charset.

Parameters:
out - An OutputStream
charsetName - The name of a supported charset

OutputStreamWriter

public OutputStreamWriter(OutputStream out)
Enabled: Create an OutputStreamWriter that uses the default character encoding.

Parameters:
out - An OutputStream

OutputStreamWriter

public OutputStreamWriter(OutputStream out,
                          java.nio.charset.Charset cs)
Enabled: Create an OutputStreamWriter that uses the given charset.

Parameters:
out - An OutputStream
Since:
1.4

OutputStreamWriter

public OutputStreamWriter(OutputStream out,
                          java.nio.charset.CharsetEncoder enc)
Enabled: Create an OutputStreamWriter that uses the given charset encoder.

Parameters:
out - An OutputStream
enc - A charset encoder
Since:
1.4
Method Detail

getEncoding

public String getEncoding()
Enabled: Return the name of the character encoding being used by this stream.

If the encoding has an historical name then that name is returned; otherwise the encoding's canonical name is returned.

If this instance was created with the OutputStreamWriter(OutputStream, String) constructor then the returned name, being unique for the encoding, may differ from the name passed to the constructor. This method may return null if the stream has been closed.

Returns:
The historical name of this encoding, or possibly null if the stream has been closed
See Also:
java.nio.charset.Charset

flushBuffer

void flushBuffer()
           throws IOException
Flush the output buffer to the underlying byte stream, without flushing the byte stream itself. This method is non-private only so that it may be invoked by PrintStream.

IOException

write

public void write(int c)
           throws IOException
Enabled: Write a single character.

Overrides:
write in class Writer
Parameters:
c - int specifying a character to be written.
IOException

write

public void write(char[] cbuf,
                  int off,
                  int len)
           throws IOException
Enabled: Write a portion of an array of characters.

Specified by:
write in class Writer
Parameters:
cbuf - Buffer of characters
off - Offset from which to start writing characters
len - Number of characters to write
IOException

write

public void write(String str,
                  int off,
                  int len)
           throws IOException
Enabled: Write a portion of a string.

Overrides:
write in class Writer
Parameters:
str - A String
off - Offset from which to start writing characters
len - Number of characters to write
IOException

flush

public void flush()
           throws IOException
Enabled: Flush the stream.

Specified by:
flush in class Writer
IOException

close

public void close()
           throws IOException
Enabled: Close the stream.

Specified by:
close in class Writer
IOException


comments?