Package com.opensymphony.module.sitemesh.util

# Class FastByteArrayOutputStream

java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
com.opensymphony.module.sitemesh.util.FastByteArrayOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

public class FastByteArrayOutputStream extends ByteArrayOutputStream
A speedy implementation of ByteArrayOutputStream. It's not synchronized, and it does not copy buffers when it's expanded. There's also no copying of the internal buffer if it's contents is extracted with the writeTo(stream) method.

Version:
  $Revision: 1.2 $
Author:
  Rickard �berg, Scott Farquhar

## Field Summary

Fields
Modifier and Type
Field
Description
`private int`
`blockSize`
`private byte[]`
`buffer`
Internal buffer.
`private LinkedList`
`buffers`
`private static final int`
`DEFAULT_BLOCK_SIZE`
`private int`
`index`
`private int`
`size`

### Fields inherited from class java.io.ByteArrayOutputStream

`buf, count`

## Constructor Summary

Constructors
Constructor
Description
`FastByteArrayOutputStream()`
`FastByteArrayOutputStream(int aSize)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`void`
`flush()`
`void`
`reset()`
`int`
`size()`
`byte[]`
`toByteArray()`
`String`
`toString()`
`String`
`toString(String enc)`
`void`
`write(byte[] data, int offset, int length)`
`void`
`write(int datum)`
`void`
`writeTo(OutputStream out)`

### Methods inherited from class java.io.ByteArrayOutputStream

`toString, toString, writeBytes`

### Methods inherited from class java.io.OutputStream

`nullOutputStream, write`

### Methods inherited from class java.lang.Object

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

## Field Details

### DEFAULT_BLOCK_SIZE

private static final int DEFAULT_BLOCK_SIZE

See Also:
  - Constant Field Values

### buffer

private byte[] buffer
Internal buffer.

### buffers

private LinkedList buffers

### index

private int index

### size

private int size

### blockSize

private int blockSize

## Constructor Details

### FastByteArrayOutputStream

public FastByteArrayOutputStream()

### FastByteArrayOutputStream

public FastByteArrayOutputStream(int aSize)

## Method Details

### writeTo

public void writeTo(OutputStream out) throws IOException

Overrides:
  `writeTo` in class `ByteArrayOutputStream`
Throws:
  `IOException`

### size

public int size()

Overrides:
  `size` in class `ByteArrayOutputStream`

### toByteArray

public byte[] toByteArray()

Overrides:
  `toByteArray` in class `ByteArrayOutputStream`

### write

public void write(int datum)

Overrides:
  `write` in class `ByteArrayOutputStream`

### write

public void write(byte[] data, int offset, int length)

Overrides:
  `write` in class `ByteArrayOutputStream`

### reset

public void reset()

Overrides:
  `reset` in class `ByteArrayOutputStream`

### toString

public String toString(String enc) throws UnsupportedEncodingException

Overrides:
  `toString` in class `ByteArrayOutputStream`
Throws:
  `UnsupportedEncodingException`

### toString

public String toString()

Overrides:
  `toString` in class `ByteArrayOutputStream`

### flush

public void flush() throws IOException

Specified by:
  `flush` in interface `Flushable`
Overrides:
  `flush` in class `OutputStream`
Throws:
  `IOException`

### close

public void close() throws IOException

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `ByteArrayOutputStream`
Throws:
  `IOException`