public class MemoryStream
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
class |
MemoryStream.Chunk
Represents a single chunk
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULTCHUNKSIZE |
| Constructor and Description |
|---|
MemoryStream()
Creates a new instance of MemoryStream.
|
MemoryStream(byte[] memory)
Creates a new instance of MemoryStream.
|
MemoryStream(byte[] memory,
int chunksize)
Creates a new instance of MemoryStream.
|
MemoryStream(int chunksize)
Creates a new instance of MemoryStream.
|
MemoryStream(java.util.List<MemoryStream.Chunk> chunkList)
Creates a new instance of MemoryStream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the memory stream.
|
void |
flush()
Flushes the stream (no effect)
|
java.util.List<MemoryStream.Chunk> |
getChunkList()
Returns the used chunk list
|
int |
getLength()
Returns the content's length
|
int |
getPosition()
Returns the position
|
int |
read(byte[] content)
Reads as much as possible into content
|
void |
seek(long offset)
Seeks to the specified offset.
|
void |
seek(long offset,
boolean stretch)
Seeks to the specified offset.
|
void |
setLength(long newLength)
Sets the new length
|
byte[] |
toArray()
Returns the content as a single byte array
|
void |
write(byte[] input)
Writes input to the memory stream.
|
public static final int DEFAULTCHUNKSIZE
public MemoryStream()
public MemoryStream(int chunksize)
chunksize - the size of each chunkpublic MemoryStream(byte[] memory)
throws java.io.IOException
memory - the initial contentjava.io.IOExceptionpublic MemoryStream(byte[] memory,
int chunksize)
throws java.io.IOException
memory - the initial contentchunksize - the size of each chunkjava.io.IOExceptionpublic MemoryStream(java.util.List<MemoryStream.Chunk> chunkList)
chunkList - the chunk listpublic void flush()
public int getLength()
public int getPosition()
public void setLength(long newLength)
throws java.io.IOException
newLength - the new lengthjava.io.IOExceptionpublic void seek(long offset)
throws java.io.IOException
offset - the offsetjava.io.IOExceptionpublic void seek(long offset,
boolean stretch)
throws java.io.IOException
offset - the offsetstretch - whether to stretch the contentjava.io.IOExceptionpublic void write(byte[] input)
throws java.io.IOException
input - the input datajava.io.IOExceptionpublic void close()
public int read(byte[] content)
throws java.io.IOException
content - the output byte arrayjava.io.IOExceptionpublic java.util.List<MemoryStream.Chunk> getChunkList()
public byte[] toArray()
throws java.io.IOException
java.io.IOException