org.codehaus.groovy.grails.web.util
Class StreamByteBuffer
java.lang.Object
org.codehaus.groovy.grails.web.util.StreamByteBuffer
public class StreamByteBuffer
- extends Object
An in-memory buffer that provides OutputStream and InputStream interfaces.
This is more efficient than using ByteArrayOutputStream/ByteArrayInputStream
This is not thread-safe, it is intended to be used by a single Thread.
- Author:
- Lari Hotari, Sagire Software Oy
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StreamByteBuffer
public StreamByteBuffer()
StreamByteBuffer
public StreamByteBuffer(int chunkSize)
StreamByteBuffer
public StreamByteBuffer(int chunkSize,
StreamByteBuffer.ReadMode readMode)
getOutputStream
public OutputStream getOutputStream()
getInputStream
public InputStream getInputStream()
writeTo
public void writeTo(OutputStream target)
throws IOException
- Throws:
IOException
readAsByteArray
public byte[] readAsByteArray()
readAsString
public String readAsString(String encoding)
throws CharacterCodingException
- Throws:
CharacterCodingException
readAsString
public String readAsString(Charset charset)
throws CharacterCodingException
- Throws:
CharacterCodingException
totalBytesUnread
public int totalBytesUnread()
allocateSpace
protected int allocateSpace()
prepareRead
protected int prepareRead()
reset
public void reset()
getReadMode
public StreamByteBuffer.ReadMode getReadMode()
setReadMode
public void setReadMode(StreamByteBuffer.ReadMode readMode)
retainAfterReadingMode
public void retainAfterReadingMode()