Package org.grails.buffer
Class StreamByteBuffer
java.lang.Object
org.grails.buffer.StreamByteBuffer
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionStreamByteBuffer(int chunkSize) StreamByteBuffer(int chunkSize, StreamByteBuffer.ReadMode readMode) -
Method Summary
Modifier and TypeMethodDescriptionprotected intvoidclear()protected intbyte[]readAsString(String encoding) readAsString(Charset charset) voidreset()voidvoidsetReadMode(StreamByteBuffer.ReadMode readMode) intvoidwriteTo(OutputStream target)
-
Constructor Details
-
StreamByteBuffer
public StreamByteBuffer() -
StreamByteBuffer
public StreamByteBuffer(int chunkSize) -
StreamByteBuffer
-
-
Method Details
-
getOutputStream
-
getInputStream
-
writeTo
- Throws:
IOException
-
readAsByteArray
public byte[] readAsByteArray() -
readAsString
- Throws:
CharacterCodingException
-
readAsString
- Throws:
CharacterCodingException
-
totalBytesUnread
public int totalBytesUnread() -
allocateSpace
protected int allocateSpace() -
prepareRead
protected int prepareRead() -
reset
public void reset() -
getReadMode
-
setReadMode
-
retainAfterReadingMode
public void retainAfterReadingMode() -
clear
public void clear()
-