Constructor | Description |
---|---|
MemoryStream() |
Create a new memory stream with initial capacity of 0.
|
MemoryStream(byte[] buffer) |
Create a new memory stream by copying from a buffer.
|
MemoryStream(byte[] buffer,
int offset,
int length) |
Create a new memory stream by copying from a buffer.
|
MemoryStream(Stream stream) |
Create a new memory stream by copying a stream.
|
MemoryStream(java.io.InputStream inStream) |
Create a new memory stream by copying the given stream.
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Close the stream and release all associated resources.
|
long |
getLength() |
Get the length of the stream in bytes.
|
int |
read(byte[] buffer) |
Read from the stream.
|
int |
read(byte[] buffer,
int offset,
int length) |
Read from the stream.
|
boolean |
seek(long position) |
Set byte position.
|
long |
tell() |
Get current byte position.
|
byte[] |
toByteArray() |
Creates a newly allocated byte array.
|
int |
transferFrom(java.io.InputStream inStream) |
Read data from the input stream and write it to this stream.
|
long |
transferTo(java.io.OutputStream outStream) |
Read data from this stream and write it to the output stream.
|
void |
write(byte[] buffer,
int offset,
int length) |
Write to the stream.
|
public MemoryStream()
public MemoryStream(byte[] buffer, int offset, int length)
buffer
- The buffer from which the initial data is copiedoffset
- The offset where the first byte from the buffer is copiedlength
- The number of bytes that are copied from the bufferpublic MemoryStream(byte[] buffer)
buffer
- The buffer from which the initial data is copiedpublic MemoryStream(Stream stream) throws java.io.IOException
stream
- The stream from which the initial data is copiedjava.io.IOException
- if an I/O error occurspublic MemoryStream(java.io.InputStream inStream) throws java.io.IOException
inStream
- The stream from which the initial data is copiedjava.io.IOException
- if an I/O error occurspublic long getLength()
public boolean seek(long position)
public long tell()
public int read(byte[] buffer, int offset, int length)
public int read(byte[] buffer)
buffer
- The buffer where the data is written topublic byte[] toByteArray()
java.lang.OutOfMemoryError
- if an array larger than 2GB would be required to store the bytes.public int transferFrom(java.io.InputStream inStream) throws java.io.IOException
inStream
- The stream from which the data is copiedjava.io.IOException
- if an I/O error occurspublic long transferTo(java.io.OutputStream outStream) throws java.io.IOException
seek(0)
.outStream
- The stream to which the data is copiedjava.io.IOException
- if an I/O error occurspublic void write(byte[] buffer, int offset, int length)