|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.commons.util.io.ByteStreamCache
public class ByteStreamCache
Byte buffer.
This class is used to store bytes and provides both an OutputStream for storing the bytes and an InputStream for reading them. It stores the bytes in memory in a highly optimized way, with a possibility of using a backing file when the content is bigger than a predefined threshold.
Nested Class Summary | |
---|---|
protected class |
ByteStreamCache.InternalInputStream
|
protected class |
ByteStreamCache.InternalOutputStream
|
Field Summary | |
---|---|
static int |
DEFAULT_BLOCKSIZE
|
static int |
DEFAULT_THRESHOLD
|
Constructor Summary | |
---|---|
ByteStreamCache()
|
|
ByteStreamCache(int blockSize)
|
|
ByteStreamCache(int blockSize,
int threshold)
|
Method Summary | |
---|---|
void |
clear()
Clear the data inside the cache. |
void |
copyFrom(java.io.InputStream is)
Init the data from an existing InputStream. |
void |
copyFrom(java.io.InputStream is,
int maxRead)
Init the data from an existing InputStream with a maximum bytes to be read. |
void |
copyFrom(java.io.ObjectInput is)
Init the data from an existing ObjectInput. |
void |
copyFrom(java.io.ObjectInput is,
int maxRead)
Init the data from an existing ObjectInput with a maximum bytes to be read. |
void |
copyTo(java.io.File f)
Copy the stream to a file. |
void |
copyTo(java.io.ObjectOutput os)
Copy the stream to another stream. |
void |
copyTo(java.io.OutputStream os)
Copy the stream to another stream. |
byte |
getByte(int pos)
Get an indexed byte. |
java.io.InputStream |
getInputStream()
Get an input stream on the stored data. |
long |
getLength()
Get the number of stored bytes. |
java.io.OutputStream |
getOutputStream()
Get an output stream to store the data. |
boolean |
isEqual(ByteStreamCache other)
|
byte[] |
toByteArray()
Convert to a byte array. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BLOCKSIZE
public static final int DEFAULT_THRESHOLD
Constructor Detail |
---|
public ByteStreamCache()
public ByteStreamCache(int blockSize)
public ByteStreamCache(int blockSize, int threshold)
Method Detail |
---|
public boolean isEqual(ByteStreamCache other)
public long getLength()
public byte getByte(int pos)
public void clear()
public java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public void copyFrom(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public void copyFrom(java.io.InputStream is, int maxRead) throws java.io.IOException
java.io.IOException
public void copyFrom(java.io.ObjectInput is) throws java.io.IOException
java.io.IOException
public void copyFrom(java.io.ObjectInput is, int maxRead) throws java.io.IOException
java.io.IOException
public void copyTo(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public void copyTo(java.io.ObjectOutput os) throws java.io.IOException
java.io.IOException
public void copyTo(java.io.File f) throws java.io.IOException
java.io.IOException
public byte[] toByteArray()
public final void write(int b) throws java.io.IOException
java.io.IOException
public final void write(byte[] b) throws java.io.IOException
java.io.IOException
public final void write(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |