Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jcontrol.io
Class ByteArrayOutputStream

    java.lang.Object
      jcontrol.io.OutputStream
          jcontrol.io.ByteArrayOutputStream

    public class ByteArrayOutputStream

extends OutputStream

The `ByteArrayOutputStream` is a simple `OutputStream` for writing data to a byte array. The byte array can either be of fixed size or expandable.

Internally a write pointer is used, which is automatically increased on write accesses. It can be reset through the `reset()` method.

Field Summary
`protected byte[]` | `m_array` Underlying byte array.
`protected int` | `m_maxSize` Maximum byte array size.
`protected int` | `m_writePos` Current writing prosition.

Constructor Summary
`ByteArrayOutputStream()` Creates a `ByteArrayOutputStream` with dynamic size.
`ByteArrayOutputStream(byte[] array)` Creates a ByteArrayOutputStream for writing to the specified array.
`ByteArrayOutputStream(int size)` Creates a ByteArrayOutputStream with a fixed size.

Method Summary
`void` | `close()` Has no effect on a `ByteArrayOutputStream`.
`void` | `flush()` Has no effect on a `ByteArrayOutputStream`.
`byte[]` | `getBytes()` Returns the underlying byte array.
`void` | `reset()` Resets the write pointer.
`void` | `write(byte[] b, int start, int length)` Writes a part of an array to the OutputStream.
`void` | `write(int b)` Writes a single byte to the OutputStream.
`void` | `writeOut(OutputStream out)` Writes the content of the underlying byte array to another `OutputStream`.

Methods inherited from class jcontrol.io.OutputStream
`write`

Methods inherited from class java.lang.Object
`clone, equals, getClass, notifyAll, toString, wait`

Field Detail

### m_array

    protected byte[] m_array

  Underlying byte array.

### m_maxSize

    protected int m_maxSize

  Maximum byte array size.

### m_writePos

    protected int m_writePos

  Current writing prosition.

Constructor Detail

### ByteArrayOutputStream

    public ByteArrayOutputStream(byte[] array)

  Creates a ByteArrayOutputStream for writing to the specified array.

  Parameters:
    `array` - byte array to write to

### ByteArrayOutputStream

    public ByteArrayOutputStream(int size)

  Creates a ByteArrayOutputStream with a fixed size. The array the stream writes to is newly created

  Parameters:
    `size` - desired array size

### ByteArrayOutputStream

    public ByteArrayOutputStream()

  Creates a `ByteArrayOutputStream` with dynamic size. The size of the underlying byte array is increased when needed.

Method Detail

### close

    public void close()

  Has no effect on a `ByteArrayOutputStream`.

  Specified by:
    `close` in class `OutputStream`

### flush

    public void flush()

  Has no effect on a `ByteArrayOutputStream`.

  Specified by:
    `flush` in class `OutputStream`

### write

    public void write(int b)

  Description copied from class: `OutputStream`
  Writes a single byte to the OutputStream.

  Specified by:
    `write` in class `OutputStream`
  Parameters:
    `b` - byte to write

### write

    public void write(byte[] b,
                      int start,
                      int length)

  Description copied from class: `OutputStream`
  Writes a part of an array to the OutputStream.

  Specified by:
    `write` in class `OutputStream`
  Parameters:
    `b` - array containing the data to send
    `start` - index of the first byte to send in the array
    `length` - number of bytes to send

### reset

    public void reset()

  Resets the write pointer.

### getBytes

    public byte[] getBytes()

  Returns the underlying byte array.

  Returns:
    byte array

### writeOut

    public void writeOut(OutputStream out)
                  throws IOException

  Writes the content of the underlying byte array to another `OutputStream`.

  Parameters:
    `out` - OutputStream
  Throws:
    `IOException` - occurs in case of I/O errors or when OutputStream `out` is closed

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD