public class MemoryStream
extends java.io.InputStream
implements java.io.Closeable
| Constructor and Description |
|---|
MemoryStream()
Initializes a new instance of the MemoryStream class with an expandable capacity
initialized to zero.
|
MemoryStream(byte[] buffer)
Initializes a new non-resizable instance of the MemoryStream class based on the
specified byte array.
|
MemoryStream(byte[] buffer,
boolean writable)
Initializes a new non-resizable instance of the MemoryStream class based on the
specified byte array, with writable set as specified.
|
MemoryStream(byte[] buffer,
int index,
int count)
Initializes a new non-resizable instance of the MemoryStream class based on the
specified region of a byte array.
|
MemoryStream(byte[] buffer,
int index,
int count,
boolean writable)
Initializes a new non-resizable instance of the MemoryStream class based on the
specified region of a byte array, with writable set as specified.
|
MemoryStream(byte[] buffer,
int index,
int count,
boolean writable,
boolean publiclyVisible)
Initializes a new instance of the MemoryStream class based on the specified region
of a byte array, with writable set as specified, and publiclyVisible set as
specified.
|
MemoryStream(int capacity)
Initializes a new instance of the MemoryStream class with an expandable capacity
initialized as specified.
|
| Modifier and Type | Method and Description |
|---|---|
java.io.OutputStream |
asOutputStream()
Get an OutputStream that will write to this MemoryStream, at the current position.
|
int |
available() |
void |
close() |
byte[] |
getBuffer()
Returns the array of bytes from which this stream was created.
|
int |
getCapacity()
Gets the number of bytes allocated for this stream.
|
long |
getLength()
Gets the length of the stream in bytes.
|
long |
getPosition()
Gets the current position within the stream.
|
void |
mark(int readAheadLimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
seek(long offset,
SeekOrigin loc)
Sets the position within the current stream to the specified value.
|
void |
setCapacity(int value)
Sets the number of bytes allocated for this stream.
|
void |
setLength(long value)
Sets the length of this stream to the given value.
|
void |
setPosition(long value)
Sets the current position within the stream.
|
long |
skip(long n) |
byte[] |
toByteArray() |
void |
write(byte[] buffer,
int offset,
int count)
Writes a block of bytes to the current stream using data read from buffer.
|
void |
writeByte(byte value) |
public MemoryStream()
public MemoryStream(int capacity)
capacity - The initial size of the internal array in bytes.public MemoryStream(byte[] buffer)
buffer - The array of unsigned bytes from which to create the current stream.public MemoryStream(byte[] buffer,
boolean writable)
buffer - The array of unsigned bytes from which to create this stream.writable - True if the stream supports writing, false otherwise.public MemoryStream(byte[] buffer,
int index,
int count)
buffer - The array of unsigned bytes from which to create this stream.index - The index into buffer at which the stream begins.count - The length of the stream in bytes.public MemoryStream(byte[] buffer,
int index,
int count,
boolean writable)
buffer - The array of unsigned bytes from which to create this stream.index - The index into buffer at which the stream begins.count - The length of the stream in bytes.writable - True if the stream supports writing, false otherwise.public MemoryStream(byte[] buffer,
int index,
int count,
boolean writable,
boolean publiclyVisible)
buffer - The array of unsigned bytes from which to create this stream.index - The index into buffer at which the stream begins.count - The length of the stream in bytes.writable - Whether the stream supports writing.publiclyVisible - Whether the stream allows direct access to the underlying buffer.public int available()
available in class java.io.InputStreampublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreampublic void mark(int readAheadLimit)
mark in class java.io.InputStreampublic boolean markSupported()
markSupported in class java.io.InputStreampublic void reset()
reset in class java.io.InputStreampublic int read()
read in class java.io.InputStreampublic int read(byte[] b,
int off,
int len)
read in class java.io.InputStreampublic long skip(long n)
skip in class java.io.InputStreampublic byte[] getBuffer()
public int getCapacity()
public void setCapacity(int value)
value - The new length of the usable portion of the buffer for the stream.public long getLength()
public void setLength(long value)
value - The new length of the stream.public long getPosition()
public void setPosition(long value)
value - The new position within the stream.public long seek(long offset,
SeekOrigin loc)
offset - The new position within the stream. This is relative to the loc
parameter, and can be positive or negative.loc - A value of type SeekOrigin, which acts as the seek reference point.public void write(byte[] buffer,
int offset,
int count)
buffer - The buffer to write data from.offset - The zero-based byte offset in buffer at which to begin copying bytes to
the current stream.count - The maximum number of bytes to write.public void writeByte(byte value)
public byte[] toByteArray()
public java.io.OutputStream asOutputStream()