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 intblockSizeprivate byte[]bufferInternal buffer.private LinkedListbuffersprivate static intDEFAULT_BLOCK_SIZEprivate intindexprivate intsize-
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
-
-
Constructor Summary
Constructors Constructor Description FastByteArrayOutputStream()FastByteArrayOutputStream(int aSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()voidreset()intsize()byte[]toByteArray()StringtoString()StringtoString(String enc)voidwrite(byte[] data, int offset, int length)voidwrite(int datum)voidwriteTo(OutputStream out)-
Methods inherited from class java.io.ByteArrayOutputStream
toString, toString, writeBytes
-
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
-
-
-
Field Detail
-
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
-
-
Method Detail
-
writeTo
public void writeTo(OutputStream out) throws IOException
- Overrides:
writeToin classByteArrayOutputStream- Throws:
IOException
-
size
public int size()
- Overrides:
sizein classByteArrayOutputStream
-
toByteArray
public byte[] toByteArray()
- Overrides:
toByteArrayin classByteArrayOutputStream
-
write
public void write(int datum)
- Overrides:
writein classByteArrayOutputStream
-
write
public void write(byte[] data, int offset, int length)- Overrides:
writein classByteArrayOutputStream
-
reset
public void reset()
- Overrides:
resetin classByteArrayOutputStream
-
toString
public String toString(String enc) throws UnsupportedEncodingException
- Overrides:
toStringin classByteArrayOutputStream- Throws:
UnsupportedEncodingException
-
toString
public String toString()
- Overrides:
toStringin classByteArrayOutputStream
-
flush
public void flush() throws IOException- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classByteArrayOutputStream- Throws:
IOException
-
-