public class OptimizedMemoryStream
extends com.aspose.ms.System.IO.Stream
Defines a MemoryStream that can contains more standard capacity
| Modifier and Type | Class and Description |
|---|---|
static class |
OptimizedMemoryStream.SeekOrigin
Specifies the position in a stream to use for seeking.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DefaultBufferSize
Default buffer size value in bytes.
|
| Constructor and Description |
|---|
OptimizedMemoryStream()
Initializes a new instance of the
OptimizedMemoryStream class. |
OptimizedMemoryStream(byte[] buffer)
Initializes a new instance of the
OptimizedMemoryStream class based on the specified byte array. |
OptimizedMemoryStream(int bufferSize)
Initializes a new instance of the
OptimizedMemoryStream class. |
OptimizedMemoryStream(int bufferSize,
byte[] buffer)
Initializes a new instance of the
OptimizedMemoryStream class based on the specified byte array. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead()
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
|
boolean |
canSeek()
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
|
boolean |
canWrite()
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
|
void |
flush()
The function overrided.
|
int |
getBufferSize()
Gets or sets the size of the underlying buffers.
|
boolean |
getFreeOnDispose()
Gets or sets a value indicating whether to free the underlying buffers on dispose.
|
long |
getLength()
When overridden in a derived class, gets the length in bytes of the stream.
|
long |
getPosition()
When overridden in a derived class, gets or sets the position within the current stream.
|
int |
read(byte[] buffer,
int offset,
int count)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
|
int |
readByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
|
long |
seek(long offset,
int origin)
When overridden in a derived class, sets the position within the current stream.
|
long |
seek(long offset,
OptimizedMemoryStream.SeekOrigin origin)
When overridden in a derived class, sets the position within the current stream.
|
void |
setBufferSize(int value)
Gets or sets the size of the underlying buffers.
|
void |
setFreeOnDispose(boolean value)
Gets or sets a value indicating whether to free the underlying buffers on dispose.
|
void |
setLength(long value)
When overridden in a derived class, sets the length of the current stream.
|
void |
setPosition(long value)
When overridden in a derived class, gets or sets the position within the current stream.
|
byte[] |
toArray()
Converts the current stream to a byte array.
|
void |
write(byte[] buffer,
int offset,
int count)
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position
within this stream by the number of bytes written.
|
void |
writeByte(byte value)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
|
void |
writeTo(com.aspose.ms.System.IO.Stream stream)
Writes to the specified stream.
|
public static final int DefaultBufferSize
Default buffer size value in bytes.
public OptimizedMemoryStream()
Initializes a new instance of the OptimizedMemoryStream class.
public OptimizedMemoryStream(int bufferSize,
byte[] buffer)
Initializes a new instance of the OptimizedMemoryStream class based on the specified byte array.
bufferSize - Size of the underlying buffers.buffer - The array of unsigned bytes from which to create the current stream.public OptimizedMemoryStream(int bufferSize)
Initializes a new instance of the OptimizedMemoryStream class.
bufferSize - Size of the underlying buffers.public OptimizedMemoryStream(byte[] buffer)
Initializes a new instance of the OptimizedMemoryStream class based on the specified byte array.
buffer - The array of unsigned bytes from which to create the current stream.public boolean canRead()
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
canRead in class com.aspose.ms.System.IO.Streampublic boolean canSeek()
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
canSeek in class com.aspose.ms.System.IO.Streampublic boolean canWrite()
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
canWrite in class com.aspose.ms.System.IO.Streampublic final int getBufferSize()
Gets or sets the size of the underlying buffers.
Value: The buffers size.public final void setBufferSize(int value)
Gets or sets the size of the underlying buffers.
Value: The buffers size.value - int valuepublic long getLength()
When overridden in a derived class, gets the length in bytes of the stream.
getLength in class com.aspose.ms.System.IO.Streampublic long getPosition()
When overridden in a derived class, gets or sets the position within the current stream.
getPosition in class com.aspose.ms.System.IO.Streampublic void setPosition(long value)
When overridden in a derived class, gets or sets the position within the current stream.
The current position within the stream. Value:setPosition in class com.aspose.ms.System.IO.Streampublic final boolean getFreeOnDispose()
Gets or sets a value indicating whether to free the underlying buffers on dispose.
public final void setFreeOnDispose(boolean value)
Gets or sets a value indicating whether to free the underlying buffers on dispose.
value - boolean valuepublic int read(byte[] buffer,
int offset,
int count)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
read in class com.aspose.ms.System.IO.Streambuffer - An array of bytes. When this method returns, the buffer contains the specified byte array with the valuesoffset - The zero-based byte offset in at which to begin storing the data read from the current stream.count - The maximum number of bytes to be read from the current stream.public int readByte()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
readByte in class com.aspose.ms.System.IO.Streampublic long seek(long offset,
OptimizedMemoryStream.SeekOrigin origin)
When overridden in a derived class, sets the position within the current stream.
offset - A byte offset relative to the origin parameter.origin - A value of type OptimizedMemoryStream.SeekOrigin indicating the reference point used to obtain the new position.public long seek(long offset,
int origin)
When overridden in a derived class, sets the position within the current stream.
seek in class com.aspose.ms.System.IO.Streamoffset - A byte offset relative to the origin parameter.origin - A value of type OptimizedMemoryStream.SeekOrigin indicating the reference point used to obtain the new position.public void flush()
The function overrided.
flush in class com.aspose.ms.System.IO.Streampublic void setLength(long value)
When overridden in a derived class, sets the length of the current stream.
setLength in class com.aspose.ms.System.IO.Streamvalue - The desired length of the current stream in bytes.public final byte[] toArray()
Converts the current stream to a byte array.
public void write(byte[] buffer,
int offset,
int count)
When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
write in class com.aspose.ms.System.IO.Streambuffer - An array of bytes. This method copies count bytes from buffer to the current stream.offset - The zero-based byte offset in buffer at which to begin copying bytes to the current stream.count - The number of bytes to be written to the current stream.public void writeByte(byte value)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
writeByte in class com.aspose.ms.System.IO.Streamvalue - The byte to write to the stream.public final void writeTo(com.aspose.ms.System.IO.Stream stream)
Writes to the specified stream.
stream - The stream.Copyright © 2025 Aspose. All Rights Reserved.