APIdia Launch Partner
Top Fields Constructors Methods
sun.nio.cs

public final Class StreamEncoder

extends Writer
Class Inheritance
Imports
java.io.IOException, .OutputStream, .UnsupportedEncodingException, .Writer, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .CharsetEncoder, .CoderResult, .CodingErrorAction, .IllegalCharsetNameException, .UnsupportedCharsetException

Field Summary

Modifier and TypeField and Description
private ByteBuffer
private volatile boolean
private final Charset
private final CharsetEncoder
private boolean
private static final int
private CharBuffer
private char
private static final int
private final int
private final OutputStream
Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
private
private
private

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Closes the stream, flushing it first.

pack-priv String
private void
public void
flush()

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Flushes the stream.

public void
private void
flushLeftoverChar(CharBuffer cb, boolean endOfInput)

public static StreamEncoder
public static StreamEncoder
public static StreamEncoder
public static StreamEncoder
public String
pack-priv void
growByteBufferIfNeeded(int len)

Grows bb to a capacity to allow len characters be encoded.

pack-priv void
pack-priv void
pack-priv void
pack-priv void
implWrite(char[] cbuf, int off, int len)

pack-priv void
private boolean
public void
write(int c)

Overrides java.io.Writer.write.

Writes a single character.

public void
write(char[] cbuf, int off, int len)

Implements abstract java.io.Writer.write.

Writes a portion of an array of characters.

public void
write(String str, int off, int len)

Overrides java.io.Writer.write.

Writes a portion of a string.

public void
private void
Inherited from java.io.Writer:
appendappendappendnullWriterwritewrite

Field Detail

bbback to summary
private ByteBuffer bb
closedback to summary
private volatile boolean closed
csback to summary
private final Charset cs
encoderback to summary
private final CharsetEncoder encoder
haveLeftoverCharback to summary
private boolean haveLeftoverChar
INITIAL_BYTE_BUFFER_CAPACITYback to summary
private static final int INITIAL_BYTE_BUFFER_CAPACITY
lcbback to summary
private CharBuffer lcb
leftoverCharback to summary
private char leftoverChar
MAX_BYTE_BUFFER_CAPACITYback to summary
private static final int MAX_BYTE_BUFFER_CAPACITY
maxBufferCapacityback to summary
private final int maxBufferCapacity
outback to summary
private final OutputStream out

Constructor Detail

StreamEncoderback to summary
private StreamEncoder(OutputStream out, Object lock, Charset cs)
StreamEncoderback to summary
private StreamEncoder(OutputStream out, Object lock, CharsetEncoder enc)
StreamEncoderback to summary
private StreamEncoder(OutputStream out, CharsetEncoder enc)

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements java.io.Closeable.close.

Doc from java.io.Writer.close.

Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.

Exceptions
IOException:
If an I/O error occurs
encodingNameback to summary
pack-priv String encodingName()
ensureOpenback to summary
private void ensureOpen() throws IOException
flushback to summary
public void flush() throws IOException

Implements abstract java.io.Writer.flush.

Implements java.io.Flushable.flush.

Doc from java.io.Writer.flush.

Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Exceptions
IOException:
If an I/O error occurs
flushBufferback to summary
public void flushBuffer() throws IOException
flushLeftoverCharback to summary
private void flushLeftoverChar(CharBuffer cb, boolean endOfInput) throws IOException
forOutputStreamWriterback to summary
public static StreamEncoder forOutputStreamWriter(OutputStream out, Object lock, String charsetName) throws UnsupportedEncodingException
forOutputStreamWriterback to summary
public static StreamEncoder forOutputStreamWriter(OutputStream out, Object lock, Charset cs)
forOutputStreamWriterback to summary
public static StreamEncoder forOutputStreamWriter(OutputStream out, Object lock, CharsetEncoder enc)
forOutputStreamWriterback to summary
public static StreamEncoder forOutputStreamWriter(OutputStream out, CharsetEncoder enc)
getEncodingback to summary
public String getEncoding()
growByteBufferIfNeededback to summary
pack-priv void growByteBufferIfNeeded(int len) throws IOException

Grows bb to a capacity to allow len characters be encoded.

implCloseback to summary
pack-priv void implClose() throws IOException
implFlushback to summary
pack-priv void implFlush() throws IOException
implFlushBufferback to summary
pack-priv void implFlushBuffer() throws IOException
implWriteback to summary
pack-priv void implWrite(char[] cbuf, int off, int len) throws IOException
implWriteback to summary
pack-priv void implWrite(CharBuffer cb) throws IOException
isOpenback to summary
private boolean isOpen()
writeback to summary
public void write(int c) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

Subclasses that intend to support efficient single-character output should override this method.

Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(char[] cbuf, int off, int len) throws IOException

Implements abstract java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of an array of characters.

Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(String str, int off, int len) throws IOException

Overrides java.io.Writer.write.

Doc from java.io.Writer.write.

Writes a portion of a string.

Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(CharBuffer cb) throws IOException
writeBytesback to summary
private void writeBytes() throws IOException