Table of Contents

Class Streams

Namespace
Org.BouncyCastle.Utilities.IO
Assembly
BouncyCastle.Cryptography.dll
public static class Streams
Inheritance
Streams
Inherited Members

Properties

DefaultBufferSize

public static int DefaultBufferSize { get; }

Property Value

int

Methods

CopyTo(Stream, Stream)

public static void CopyTo(Stream source, Stream destination)

Parameters

source Stream
destination Stream

CopyTo(Stream, Stream, int)

public static void CopyTo(Stream source, Stream destination, int bufferSize)

Parameters

source Stream
destination Stream
bufferSize int

CopyToAsync(Stream, Stream)

public static Task CopyToAsync(Stream source, Stream destination)

Parameters

source Stream
destination Stream

Returns

Task

CopyToAsync(Stream, Stream, int)

public static Task CopyToAsync(Stream source, Stream destination, int bufferSize)

Parameters

source Stream
destination Stream
bufferSize int

Returns

Task

CopyToAsync(Stream, Stream, int, CancellationToken)

public static Task CopyToAsync(Stream source, Stream destination, int bufferSize, CancellationToken cancellationToken)

Parameters

source Stream
destination Stream
bufferSize int
cancellationToken CancellationToken

Returns

Task

CopyToAsync(Stream, Stream, CancellationToken)

public static Task CopyToAsync(Stream source, Stream destination, CancellationToken cancellationToken)

Parameters

source Stream
destination Stream
cancellationToken CancellationToken

Returns

Task

Drain(Stream)

public static void Drain(Stream inStr)

Parameters

inStr Stream

PipeAll(Stream, Stream)

Write the full contents of inStr to the destination stream outStr.

public static void PipeAll(Stream inStr, Stream outStr)

Parameters

inStr Stream

Source stream.

outStr Stream

Destination stream.

Exceptions

IOException

In case of IO failure.

PipeAll(Stream, Stream, int)

Write the full contents of inStr to the destination stream outStr.

public static void PipeAll(Stream inStr, Stream outStr, int bufferSize)

Parameters

inStr Stream

Source stream.

outStr Stream

Destination stream.

bufferSize int

The size of temporary buffer to use.

Exceptions

IOException

In case of IO failure.

PipeAllLimited(Stream, long, Stream)

Pipe all bytes from inStr to outStr, throwing StreamFlowException if greater than limit bytes in inStr.

public static long PipeAllLimited(Stream inStr, long limit, Stream outStr)

Parameters

inStr Stream

A Stream

limit long

A long

outStr Stream

A Stream

Returns

long

The number of bytes actually transferred, if not greater than limit

Exceptions

IOException

PipeAllLimited(Stream, long, Stream, int)

public static long PipeAllLimited(Stream inStr, long limit, Stream outStr, int bufferSize)

Parameters

inStr Stream
limit long
outStr Stream
bufferSize int

Returns

long

ReadAll(MemoryStream)

[Obsolete("Will be removed")]
public static byte[] ReadAll(MemoryStream inStr)

Parameters

inStr MemoryStream

Returns

byte[]

ReadAll(Stream)

public static byte[] ReadAll(Stream inStr)

Parameters

inStr Stream

Returns

byte[]

ReadAllLimited(Stream, int)

public static byte[] ReadAllLimited(Stream inStr, int limit)

Parameters

inStr Stream
limit int

Returns

byte[]

ReadAsync(Stream, Memory<byte>, CancellationToken)

public static ValueTask<int> ReadAsync(Stream source, Memory<byte> buffer, CancellationToken cancellationToken = default)

Parameters

source Stream
buffer Memory<byte>
cancellationToken CancellationToken

Returns

ValueTask<int>

ReadFully(Stream, byte[])

public static int ReadFully(Stream inStr, byte[] buf)

Parameters

inStr Stream
buf byte[]

Returns

int

ReadFully(Stream, byte[], int, int)

public static int ReadFully(Stream inStr, byte[] buf, int off, int len)

Parameters

inStr Stream
buf byte[]
off int
len int

Returns

int

ReadFully(Stream, Span<byte>)

public static int ReadFully(Stream inStr, Span<byte> buffer)

Parameters

inStr Stream
buffer Span<byte>

Returns

int

ValidateBufferArguments(byte[], int, int)

public static void ValidateBufferArguments(byte[] buffer, int offset, int count)

Parameters

buffer byte[]
offset int
count int

WriteAsync(Stream, ReadOnlyMemory<byte>, CancellationToken)

public static ValueTask WriteAsync(Stream destination, ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)

Parameters

destination Stream
buffer ReadOnlyMemory<byte>
cancellationToken CancellationToken

Returns

ValueTask

WriteBufTo(MemoryStream, byte[], int)

public static int WriteBufTo(MemoryStream buf, byte[] output, int offset)

Parameters

buf MemoryStream
output byte[]
offset int

Returns

int

Exceptions

IOException