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

FieldDescription
DefaultBufferSizeDefault buffer size value in bytes.

Constructors

ConstructorDescription
OptimizedMemoryStreamInitializes a new instance of the {@link OptimizedMemoryStream} class.
OptimizedMemoryStreamInitializes a new instance of the {@link OptimizedMemoryStream} class based on the specified byte array.
OptimizedMemoryStreamInitializes a new instance of the {@link OptimizedMemoryStream} class.
OptimizedMemoryStreamInitializes a new instance of the {@link OptimizedMemoryStream} class based on the specified byte array.

Methods

MethodDescription
canReadWhen overridden in a derived class, gets a value indicating whether the current stream supports reading.
canSeekWhen overridden in a derived class, gets a value indicating whether the current stream supports seeking.
canWriteWhen overridden in a derived class, gets a value indicating whether the current stream supports writing.
flushThe function overrided.
getBufferSizeGets or sets the size of the underlying buffers. Value: The buffers size.
getFreeOnDisposeGets or sets a value indicating whether to free the underlying buffers on dispose.
getLengthWhen overridden in a derived class, gets the length in bytes of the stream.
getPositionWhen overridden in a derived class, gets or sets the position within the current stream.
readWhen 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.
readByteReads 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.
seekWhen overridden in a derived class, sets the position within the current stream.
seekWhen overridden in a derived class, sets the position within the current stream.
setBufferSizeGets or sets the size of the underlying buffers. Value: The buffers size.
setFreeOnDisposeGets or sets a value indicating whether to free the underlying buffers on dispose.
setLengthWhen overridden in a derived class, sets the length of the current stream.
setPositionWhen overridden in a derived class, gets or sets the position within the current stream. The current position within the stream. Value:
toArrayConverts the current stream to a byte array.
writeWhen 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.
writeByteWrites a byte to the current position in the stream and advances the position within the stream by one byte.
writeToWrites 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:

ParameterTypeDescription
bufferThe 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:

ParameterTypeDescription
bufferSizeSize 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:

ParameterTypeDescription
bufferSizeSize of the underlying buffers.
bufferThe 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:

ParameterTypeDescription
bufferAn array of bytes. When this method returns, the buffer contains the specified byte array with the values
offsetThe zero-based byte offset in at which to begin storing the data read from the current stream.
countThe 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:

ParameterTypeDescription
offsetA byte offset relative to the {@code origin} parameter.
originA 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:

ParameterTypeDescription
valueint value

setFreeOnDispose

public final void setFreeOnDispose(boolean value)

Gets or sets a value indicating whether to free the underlying buffers on dispose.

Parameters:

ParameterTypeDescription
valueboolean value

setLength

public void setLength(long value)

When overridden in a derived class, sets the length of the current stream.

Parameters:

ParameterTypeDescription
valueThe 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:

ParameterTypeDescription
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:

ParameterTypeDescription
bufferAn array of bytes. This method copies {@code count} bytes from {@code buffer} to the current stream.
offsetThe zero-based byte offset in {@code buffer} at which to begin copying bytes to the current stream.
countThe 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:

ParameterTypeDescription
valueThe byte to write to the stream.

writeTo

Writes to the specified stream.