OptimizedMemoryStream

Inheritance: java.lang.Object, com.aspose.ms.System.IO.Stream

public class OptimizedMemoryStream extends System.IO.Stream

Defines a MemoryStream that can contains more standard capacity

Constructors

ConstructorDescription
OptimizedMemoryStream()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.
OptimizedMemoryStream(int bufferSize)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.

Fields

FieldDescription
DefaultBufferSizeDefault buffer size value in bytes.

Methods

MethodDescription
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.
getBufferSize()Gets or sets the size of the underlying buffers.
setBufferSize(int value)Gets or sets the size of the underlying buffers.
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.
setPosition(long value)When overridden in a derived class, gets or sets the position within the current stream.
getFreeOnDispose()Gets or sets a value indicating whether to free the underlying buffers on dispose.
setFreeOnDispose(boolean value)Gets or sets a value indicating whether to free the underlying buffers on dispose.
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.
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(long offset, int origin)When overridden in a derived class, sets the position within the current stream.
flush()The function overrided.
setLength(long value)When overridden in a derived class, sets the length of the current stream.
toArray()Converts the current stream to a byte array.
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.
writeByte(byte value)Writes a byte to the current position in the stream and advances the position within the stream by one byte.
writeTo(System.IO.Stream stream)Writes to the specified stream.

OptimizedMemoryStream()

public OptimizedMemoryStream()

Initializes a new instance of the OptimizedMemoryStream class.

OptimizedMemoryStream(int bufferSize, byte[] buffer)

public OptimizedMemoryStream(int bufferSize, byte[] buffer)

Initializes a new instance of the OptimizedMemoryStream class based on the specified byte array.

Parameters:

ParameterTypeDescription
bufferSizeintSize of the underlying buffers.
bufferbyte[]The array of unsigned bytes from which to create the current stream.

OptimizedMemoryStream(int bufferSize)

public OptimizedMemoryStream(int bufferSize)

Initializes a new instance of the OptimizedMemoryStream class.

Parameters:

ParameterTypeDescription
bufferSizeintSize of the underlying buffers.

OptimizedMemoryStream(byte[] buffer)

public OptimizedMemoryStream(byte[] buffer)

Initializes a new instance of the OptimizedMemoryStream class based on the specified byte array.

Parameters:

ParameterTypeDescription
bufferbyte[]The array of unsigned bytes from which to create the current stream.

DefaultBufferSize

public static final int DefaultBufferSize

Default buffer size value in bytes.

canRead()

public boolean canRead()

When overridden in a derived class, gets a value indicating whether the current stream supports reading.

Returns: boolean - 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: boolean - 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: boolean - true if the stream supports writing; otherwise, false. Value:

getBufferSize()

public final int getBufferSize()

Gets or sets the size of the underlying buffers.

Value: The buffers size.

Returns: int - int value

setBufferSize(int value)

public final void setBufferSize(int value)

Gets or sets the size of the underlying buffers.

Value: The buffers size.

Parameters:

ParameterTypeDescription
valueintint value

getLength()

public long getLength()

When overridden in a derived class, gets the length in bytes of the stream.

Returns: long - 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: long - The current position within the stream. Value:

setPosition(long value)

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
valuelong

getFreeOnDispose()

public final boolean getFreeOnDispose()

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

Returns: boolean - boolean value

setFreeOnDispose(boolean value)

public final void setFreeOnDispose(boolean value)

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

Parameters:

ParameterTypeDescription
valuebooleanboolean value

read(byte[] buffer, int offset, int count)

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
bufferbyte[]An array of bytes. When this method returns, the buffer contains the specified byte array with the values
offsetintThe zero-based byte offset in at which to begin storing the data read from the current stream.
countintThe maximum number of bytes to be read from the current stream.

Returns: int - 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: int - byte or -1 if at the end of the stream.

seek(long offset, int origin)

public long seek(long offset, int origin)

When overridden in a derived class, sets the position within the current stream.

Parameters:

ParameterTypeDescription
offsetlongA byte offset relative to the origin parameter.
originintA value of type SeekOrigin indicating the reference point used to obtain the new position.

Returns: long - The new position within the current stream.

flush()

public void flush()

The function overrided.

setLength(long value)

public void setLength(long value)

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

Parameters:

ParameterTypeDescription
valuelongThe desired length of the current stream in bytes.

toArray()

public final byte[] toArray()

Converts the current stream to a byte array.

Returns: byte[] - An array of bytes

write(byte[] buffer, int offset, int count)

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
bufferbyte[]An array of bytes. This method copies count bytes from buffer to the current stream.
offsetintThe zero-based byte offset in buffer at which to begin copying bytes to the current stream.
countintThe number of bytes to be written to the current stream.

writeByte(byte value)

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
valuebyteThe byte to write to the stream.

writeTo(System.IO.Stream stream)

public final void writeTo(System.IO.Stream stream)

Writes to the specified stream.

Parameters:

ParameterTypeDescription
streamcom.aspose.ms.System.IO.StreamThe stream.