Skip to content

StreamExtensions Class ​

Definition ​

Extension methods for the Stream class

  • Namespace: JASE.Extensions
  • Assembly: JASE.Primitives.dll

Methods ​

NameDescription
Encoding GetEncoding(Stream stream)Analyze the beginning of the stream to determine encoding
byte[] ReadToEnd(Stream stream)Returns stream content as an array of bytes
Task<byte[]> ReadToEndAsync(Stream stream, CancellationToken cancellationToken = null)Asynchronously reads the entire stream content into a byte array.
string StreamToText(Stream stream)Returns stream content as a string
string StreamToText(Stream stream, out Encoding encoding)Returns stream content as a string
Task<string> StreamToTextAsync(Stream stream, CancellationToken cancellationToken = null)Asynchronously returns the stream content as a string.
Task<string> StreamToTextAsync(Stream stream, Encoding encoding, CancellationToken cancellationToken = null)Asynchronously returns the stream content as a string using the specified encoding.