Show / Hide Table of Contents

Class BinaryMemoryStream

A MemoryStream implementation whose primary purpose is to be used to create Binary objects.

Inheritance
object
MarshalByRefObject
Stream
MemoryStream
BinaryMemoryStream
Implements
IAsyncDisposable
IDisposable
Inherited Members
MemoryStream.BeginRead(byte[], int, int, AsyncCallback, object)
MemoryStream.BeginWrite(byte[], int, int, AsyncCallback, object)
MemoryStream.CopyTo(Stream, int)
MemoryStream.CopyToAsync(Stream, int, CancellationToken)
MemoryStream.EndRead(IAsyncResult)
MemoryStream.EndWrite(IAsyncResult)
MemoryStream.Flush()
MemoryStream.FlushAsync(CancellationToken)
MemoryStream.Read(byte[], int, int)
MemoryStream.Read(Span<byte>)
MemoryStream.ReadAsync(byte[], int, int, CancellationToken)
MemoryStream.ReadAsync(Memory<byte>, CancellationToken)
MemoryStream.ReadByte()
MemoryStream.Seek(long, SeekOrigin)
MemoryStream.ToArray()
MemoryStream.TryGetBuffer(out ArraySegment<byte>)
MemoryStream.Write(ReadOnlySpan<byte>)
MemoryStream.WriteAsync(byte[], int, int, CancellationToken)
MemoryStream.WriteAsync(ReadOnlyMemory<byte>, CancellationToken)
MemoryStream.WriteTo(Stream)
MemoryStream.CanRead
MemoryStream.CanSeek
MemoryStream.Capacity
MemoryStream.Length
MemoryStream.Position
Stream.Null
Stream.Close()
Stream.CopyTo(Stream)
Stream.CopyToAsync(Stream)
Stream.CopyToAsync(Stream, int)
Stream.CopyToAsync(Stream, CancellationToken)
Stream.Dispose()
Stream.DisposeAsync()
Stream.FlushAsync()
Stream.ReadAsync(byte[], int, int)
Stream.Synchronized(Stream)
Stream.WriteAsync(byte[], int, int)
Stream.CanTimeout
Stream.ReadTimeout
Stream.WriteTimeout
MarshalByRefObject.GetLifetimeService()
MarshalByRefObject.InitializeLifetimeService()
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public sealed class BinaryMemoryStream : MemoryStream, IAsyncDisposable, IDisposable

Constructors

BinaryMemoryStream()

Initializes a new instance of the BinaryMemoryStream with an expandable capacity initialized to zero.

Declaration
public BinaryMemoryStream()

BinaryMemoryStream(int)

Initializes a new instance of the BinaryMemoryStream with an expandable capacity initialized as specified.

Declaration
public BinaryMemoryStream(int capacity)
Parameters
Type Name Description
int capacity

The initial size of the internal array in bytes.

Exceptions
Type Condition
ArgumentOutOfRangeException

Capacity is negative.

Properties

CanWrite

Gets a value indicating whether the current stream supports writing.

Declaration
public override bool CanWrite { get; }
Property Value
Type Description
bool

true if the stream supports writing; otherwise, false.

Overrides
MemoryStream.CanWrite

Methods

GetBuffer()

Returns the array of unsigned bytes from which this stream was created.

Declaration
public override byte[] GetBuffer()
Returns
Type Description
byte[]

The byte array from which this stream was created.

Overrides
MemoryStream.GetBuffer()
Exceptions
Type Condition
UnauthorizedAccessException

Buffer is not publicly visible.

SetLength(long)

Sets the length of the current stream to the specified value.

Declaration
public override void SetLength(long value)
Parameters
Type Name Description
long value

The value at which to set the length.

Overrides
MemoryStream.SetLength(long)
Exceptions
Type Condition
NotSupportedException

The current stream is not resizable and value is larger than the current capacity or the current stream does not support writing.

ArgumentOutOfRangeException

Value is negative or is greater than the maximum length of the stream, where the maximum length is (System.Int32.MaxValue - origin), and origin is the index into the underlying buffer at which the stream starts.

ToBinary()

Returns a new Binary object that holds the complete contents of this stream.

Declaration
public Binary ToBinary()
Returns
Type Description
Binary

The contents of this stream as a Binary object.

Write(byte[], int, int)

Writes a block of bytes to the current stream using data read from buffer.

Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type Name Description
byte[] buffer

The buffer to write data from.

int offset

The byte offset in buffer at which to begin writing from.

int count

The maximum number of bytes to write.

Overrides
MemoryStream.Write(byte[], int, int)
Exceptions
Type Condition
ArgumentNullException

Buffer is null.

NotSupportedException

The stream does not support writing or the current position is closer than count bytes to the end of the stream, and the capacity cannot be modified.

ArgumentException

Offset subtracted from the buffer length is less than count.

ArgumentOutOfRangeException

Offset or count are negative.

IOException

An I/O error occurs.

ObjectDisposedException

The current stream instance is closed.

WriteByte(byte)

Writes a byte to the current stream at the current position.

Declaration
public override void WriteByte(byte value)
Parameters
Type Name Description
byte value

The byte to write.

Overrides
MemoryStream.WriteByte(byte)
Exceptions
Type Condition
NotSupportedException

The stream does not support writing or the current position is at the end of the stream, and the capacity cannot be modified.

ObjectDisposedException

The current stream is closed.

Implements

IAsyncDisposable
IDisposable
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.