All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

  • Field Summary

    Fields

    protected byte[]

    The buffer where data is stored.

    protected int

    The number of valid bytes in the buffer.

  • Constructor Summary

    Constructors

    Creates a new ByteArrayOutputStream.

    ByteArrayOutputStream(int size)

    Creates a new ByteArrayOutputStream, with a buffer capacity of the specified size, in bytes.

  • Method Summary

    void

    close()

    Closing a ByteArrayOutputStream has no effect.

    void

    reset()

    Resets the count field of this ByteArrayOutputStream to zero, so that all currently accumulated output in the output stream is discarded.

    int

    size()

    Returns the current size of the buffer.

    byte[]

    Creates a newly allocated byte array.

    toString()

    Converts the buffer's contents into a string decoding bytes using the default charset.

    toString(int hibyte)

    Converts the buffer's contents into a string by decoding the bytes using the named charset.

    Converts the buffer's contents into a string by decoding the bytes using the specified charset.

    void

    write(byte[] b, int off, int len)

    Writes len bytes from the specified byte array starting at offset off to this ByteArrayOutputStream.

    void

    write(int b)

    Writes the specified byte to this ByteArrayOutputStream.

    void

    writeBytes(byte[] b)

    Writes the complete contents of the specified byte array to this ByteArrayOutputStream.

    void

    Writes the complete contents of this ByteArrayOutputStream to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).

    Methods declared in class OutputStream

    flush, nullOutputStream, write

    void

    Flushes this output stream and forces any buffered output bytes to be written out.

    Returns a new OutputStream which discards all bytes.

    void

    Writes b.length bytes from the specified byte array to this output stream.

    Methods declared in class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Creates and returns a copy of this object.

    boolean

    Indicates whether some other object is "equal to" this one.

    protected void

    Deprecated, for removal: This API element is subject to removal in a future version.

    Returns the runtime class of this Object.

    int

    Returns a hash code value for this object.

    final void

    Wakes up a single thread that is waiting on this object's monitor.

    final void

    Wakes up all threads that are waiting on this object's monitor.

    final void

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

    final void

    wait(long timeoutMillis)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

    final void

    wait(long timeoutMillis, int nanos)

    Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

  • Field Details

    • buf

    • count

  • Constructor Details

    • ByteArrayOutputStream

    • ByteArrayOutputStream

  • Method Details

    • write

    • write

    • writeBytes

    • writeTo

    • reset

    • toByteArray

    • size

    • toString

    • toString

    • toString

    • toString

    • close