OptimizedMemoryStream
Inheritance: java.lang.Object, com.aspose.ms.System.IO.Stream com.aspose.pdf.OptimizedMemoryStream, com.aspose.ms.System.IO.Stream, com.aspose.pdf.OptimizedMemoryStream
All Implemented Interfaces: com.aspose.ms.System.IDisposable
public class OptimizedMemoryStream extends com.aspose.ms.System.IO.Stream
Defines a MemoryStream that can contains more standard capacity
Fields
| Field | Description |
|---|---|
| DefaultBufferSize | Default buffer size value in bytes. |
Constructors
| Constructor | Description |
|---|---|
| OptimizedMemoryStream | Initializes a new instance of the {@link OptimizedMemoryStream} class. |
| OptimizedMemoryStream | Initializes a new instance of the {@link OptimizedMemoryStream} class based on the specified byte array. |
| OptimizedMemoryStream | Initializes a new instance of the {@link OptimizedMemoryStream} class. |
| OptimizedMemoryStream | Initializes a new instance of the {@link OptimizedMemoryStream} class based on the specified byte array. |
Methods
| Method | Description |
|---|---|
| canRead | When overridden in a derived class, gets a value indicating whether the current stream supports reading. |
| canSeek | When overridden in a derived class, gets a value indicating whether the current stream supports seeking. |
| canWrite | When overridden in a derived class, gets a value indicating whether the current stream supports writing. |
| flush | The function overrided. |
| getBufferSize | Gets or sets the size of the underlying buffers. Value: The buffers size. |
| getFreeOnDispose | Gets or sets a value indicating whether to free the underlying buffers on dispose. |
| getLength | When overridden in a derived class, gets the length in bytes of the stream. |
| getPosition | When overridden in a derived class, gets or sets the position within the current stream. |
| read | 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. |
| 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. |
| seek | When overridden in a derived class, sets the position within the current stream. |
| seek | When overridden in a derived class, sets the position within the current stream. |
| setBufferSize | Gets or sets the size of the underlying buffers. Value: The buffers size. |
| setFreeOnDispose | Gets or sets a value indicating whether to free the underlying buffers on dispose. |
| setLength | When overridden in a derived class, sets the length of the current stream. |
| setPosition | When overridden in a derived class, gets or sets the position within the current stream. The current position within the stream. Value: |
| toArray | Converts the current stream to a byte array. |
| write | 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. |
| writeByte | Writes a byte to the current position in the stream and advances the position within the stream by one byte. |
| writeTo | Writes to the specified stream. |
DefaultBufferSize
public static final int DefaultBufferSize
Default buffer size value in bytes.
OptimizedMemoryStream
public OptimizedMemoryStream()
Initializes a new instance of the {@link OptimizedMemoryStream} class.
OptimizedMemoryStream
public OptimizedMemoryStream(byte[] buffer)
Initializes a new instance of the {@link OptimizedMemoryStream} class based on the specified byte array.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| buffer | The array of unsigned bytes from which to create the current stream. |
OptimizedMemoryStream
public OptimizedMemoryStream(int bufferSize)
Initializes a new instance of the {@link OptimizedMemoryStream} class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| bufferSize | Size of the underlying buffers. |
OptimizedMemoryStream
public OptimizedMemoryStream(int bufferSize, byte[] buffer)
Initializes a new instance of the {@link OptimizedMemoryStream} class based on the specified byte array.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| bufferSize | Size of the underlying buffers. | |
| buffer | The array of unsigned bytes from which to create the current stream. |
canRead
public boolean canRead()
When overridden in a derived class, gets a value indicating whether the current stream supports reading.
Returns: true if the stream supports reading; otherwise, false. Value:
canSeek
public boolean canSeek()
When overridden in a derived class, gets a value indicating whether the current stream supports seeking.
Returns: true if the stream supports seeking; otherwise, false. Value:
canWrite
public boolean canWrite()
When overridden in a derived class, gets a value indicating whether the current stream supports writing.
Returns: true if the stream supports writing; otherwise, false. Value:
flush
public void flush()
The function overrided.
getBufferSize
public final int getBufferSize()
Gets or sets the size of the underlying buffers. Value: The buffers size.
Returns: int value
getFreeOnDispose
public final boolean getFreeOnDispose()
Gets or sets a value indicating whether to free the underlying buffers on dispose.
Returns: boolean value
getLength
public long getLength()
When overridden in a derived class, gets the length in bytes of the stream.
Returns: A long value representing the length of the stream in bytes. Value:
getPosition
public long getPosition()
When overridden in a derived class, gets or sets the position within the current stream.
Returns: The current position within the stream. Value:
read
public 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.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| buffer | An array of bytes. When this method returns, the buffer contains the specified byte array with the values | |
| offset | 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. |
Returns: The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
readByte
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.
Returns: byte or -1 if at the end of the stream.
seek
public long seek(long offset, int origin)
When overridden in a derived class, sets the position within the current stream.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| offset | A byte offset relative to the {@code origin} parameter. | |
| origin | A value of type {@link SeekOrigin} indicating the reference point used to obtain the new position. |
Returns: The new position within the current stream.
seek
When overridden in a derived class, sets the position within the current stream.
setBufferSize
public final void setBufferSize(int value)
Gets or sets the size of the underlying buffers. Value: The buffers size.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | int value |
setFreeOnDispose
public final void setFreeOnDispose(boolean value)
Gets or sets a value indicating whether to free the underlying buffers on dispose.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | boolean value |
setLength
public void setLength(long value)
When overridden in a derived class, sets the length of the current stream.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | The desired length of the current stream in bytes. |
setPosition
public 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:
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value |
toArray
public final byte[] toArray()
Converts the current stream to a byte array.
Returns: An array of bytes
write
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.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| buffer | An array of bytes. This method copies {@code count} bytes from {@code buffer} to the current stream. | |
| offset | The zero-based byte offset in {@code buffer} at which to begin copying bytes to the current stream. | |
| count | The number of bytes to be written to the current stream. |
writeByte
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.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | The byte to write to the stream. |
writeTo
Writes to the specified stream.