Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright 2012-04-26 Werner Randelshofer
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.monte.media.io
Class SeekableByteArrayOutputStream

    java.lang.Object
      java.io.OutputStream
          java.io.ByteArrayOutputStream
              org.monte.media.io.SeekableByteArrayOutputStream

All Implemented Interfaces:
  java.io.Closeable, java.io.Flushable

    public class SeekableByteArrayOutputStream

extends java.io.ByteArrayOutputStream

`SeekableByteArrayOutputStream`.

Version:
  $Id: SeekableByteArrayOutputStream.java 134 2011-12-02 16:23:00Z werner $
Author:
  Werner Randelshofer

Field Summary

Fields inherited from class java.io.ByteArrayOutputStream
`buf, count`

Constructor Summary
`SeekableByteArrayOutputStream()` Creates a new byte array output stream.
`SeekableByteArrayOutputStream(byte[] buf)` Creates a new byte array output stream, which reuses the supplied buffer.
`SeekableByteArrayOutputStream(int size)` Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

Method Summary
`byte[]` | `getBuffer()` Returns the underlying byte buffer.
`long` | `getStreamPosition()` Returns the current byte position of the stream.
`void` | `reset()` Resets the `count` field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded.
`void` | `seek(long pos)` Sets the current stream position to the desired location.
`void` | `toOutputStream(java.io.OutputStream out)` Writes the contents of the byte array into the specified output stream.
`void` | `write(byte[] b, int off, int len)` Writes `len` bytes from the specified byte array starting at offset `off` to this byte array output stream.
`void` | `write(int b)` Writes the specified byte to this byte array output stream.

Methods inherited from class java.io.ByteArrayOutputStream
`close, size, toByteArray, toString, toString, toString, writeTo`

Methods inherited from class java.io.OutputStream
`flush, write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### SeekableByteArrayOutputStream

    public SeekableByteArrayOutputStream()

  Creates a new byte array output stream. The buffer capacity is initially 32 bytes, though its size increases if necessary.

### SeekableByteArrayOutputStream

    public SeekableByteArrayOutputStream(int size)

  Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

  Parameters:
    `size` - the initial size.
  Throws:
    `java.lang.IllegalArgumentException` - if size is negative.

### SeekableByteArrayOutputStream

    public SeekableByteArrayOutputStream(byte[] buf)

  Creates a new byte array output stream, which reuses the supplied buffer.

Method Detail

### write

    public void write(int b)

  Writes the specified byte to this byte array output stream.

  Overrides:
    `write` in class `java.io.ByteArrayOutputStream`
  Parameters:
    `b` - the byte to be written.

### write

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

  Writes `len` bytes from the specified byte array starting at offset `off` to this byte array output stream.

  Overrides:
    `write` in class `java.io.ByteArrayOutputStream`
  Parameters:
    `b` - the data.
    `off` - the start offset in the data.
    `len` - the number of bytes to write.

### reset

    public void reset()

  Resets the `count` field of this byte array output stream to zero, so that all currently accumulated output in the output stream is discarded. The output stream can be used again, reusing the already allocated buffer space.

  Overrides:
    `reset` in class `java.io.ByteArrayOutputStream`
  See Also:
    `ByteArrayInputStream.count`

### seek

    public void seek(long pos)
              throws java.io.IOException

  Sets the current stream position to the desired location. The next read will occur at this location. The bit offset is set to 0.

  An `IndexOutOfBoundsException` will be thrown if `pos` is smaller than the flushed position (as returned by `getflushedPosition`).

  It is legal to seek past the end of the file; an `EOFException` will be thrown only if a read is performed.

  Parameters:
    `pos` - a `long` containing the desired file pointer position.
  Throws:
    `java.lang.IndexOutOfBoundsException` - if `pos` is smaller than the flushed position.
    `java.io.IOException` - if any other I/O error occurs.

### getStreamPosition

    public long getStreamPosition()
                           throws java.io.IOException

  Returns the current byte position of the stream. The next write will take place starting at this offset.

  Returns:
    a long containing the position of the stream.
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### toOutputStream

    public void toOutputStream(java.io.OutputStream out)
                        throws java.io.IOException

  Writes the contents of the byte array into the specified output stream.

  Parameters:
    `out` -
  Throws:
    `java.io.IOException`

### getBuffer

    public byte[] getBuffer()

  Returns the underlying byte buffer.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright 2012-04-26 Werner Randelshofer
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD