PeanutButter
|
Provides utility extensions on Stream objects. More...
Static Public Member Functions | |
static byte[] | ReadAllBytes (this Stream src) |
Reads all bytes from a stream. | |
static async Task< byte[]> | ReadAllBytesAsync (this Stream src) |
Reads all bytes from a stream. | |
static void | WriteAllBytes (this Stream source, byte[] data) |
Writes all given bytes to a stream. | |
static async Task | WriteAllBytesAsync (this Stream source, byte[] data) |
Writes all given bytes to a stream. | |
static void | Rewind (this Stream src) |
Rewinds the current stream pointer to the beginning of the stream (when supported by the stream) | |
static void | Append (this Stream target, byte[] data) |
Appends binary data to the end of the stream. | |
static async Task | AppendAsync (this Stream target, byte[] data) |
Appends binary data to the end of the stream. | |
static string | AsString (this Stream src, Encoding encoding=null) |
Attempts to get a string representation of the contents of a stream. | |
static async Task< string > | AsStringAsync (this Stream src, Encoding encoding=null) |
Attempts to get a string representation of the contents of a stream. | |
static void | WriteString (this Stream stream, string data) |
Invokes WriteString() with the UTF8 Encoding. | |
static async Task | WriteStringAsync (this Stream stream, string data) |
Invokes WriteString() with the UTF8 Encoding. | |
static void | WriteString (this Stream stream, string data, Encoding encoding) |
Writes a string to a stream with the provided encoding. | |
static async Task | WriteStringAsync (this Stream stream, string data, Encoding encoding) |
Writes a string to a stream with the provided encoding. | |
static void | Save (this Stream stream, string filePath) |
Saves a stream to a local file. | |
static async Task | SaveAsync (this Stream stream, string filePath) |
Saves a stream to a local file. | |
static void | AppendString (this Stream stream, string value) |
Appends a string to a stream. | |
static void | AppendLine (this Stream stream, string line) |
Appends a text line to a stream. | |
static IEnumerable< string > | ReadLines (this Stream stream) |
Reads the stream, line-for-line, with the UTF8 encoding. | |
static IEnumerable< string > | ReadLines (this Stream stream, Action< Eol > onNewline) |
Reads the stream, line-for-line, with the UTF8 encoding. When a newline is encountered, the onNewLine func is called with the kind of line ending last encountered. | |
static IEnumerable< string > | ReadLines (this Stream stream, Encoding encoding) |
Reads the stream, line-for-line, with the provided encoding. | |
static IEnumerable< string > | ReadLines (this Stream stream, Encoding encoding, Action< Eol > onNewLine) |
Reads the stream, line-for-line, with the provided encoding. When a newline is encountered, the onNewLine func is called with the kind of line ending last encountered. | |
static string | ReadLine (this Stream stream) |
Read one line from the stream, encoded as utf8. | |
static string | ReadLine (this Stream stream, Encoding encoding) |
Read one line from the stream, with the provided encoding. | |
static string | ReadAllText (this Stream stream) |
Read all content of a stream as text with utf8 encoding. | |
static string | ReadAllText (this Stream stream, Encoding encoding) |
Read all content of a stream as text with the provided encoding. | |
static async Task< string > | ReadAllTextAsync (this Stream stream) |
Read all content of a stream as text with utf8 encoding. | |
static async Task< string > | ReadAllTextAsync (this Stream stream, Encoding encoding) |
Read all content of a stream as text with the provided encoding. |
Provides utility extensions on Stream objects.
|
static |
Appends binary data to the end of the stream.
target | Target stream to write to |
data | Binary data to write |
IOException | Thrown when the target stream is null |
|
static |
Appends binary data to the end of the stream.
target | Target stream to write to |
data | Binary data to write |
IOException | Thrown when the target stream is null |
|
static |
Appends a text line to a stream.
stream | |
line |
|
static |
Appends a string to a stream.
stream | |
value |
|
static |
Attempts to get a string representation of the contents of a stream.
src | Source stream to read |
encoding | Optional encoding to use (defaults to UTF8 when null) |
|
static |
Attempts to get a string representation of the contents of a stream.
src | Source stream to read |
encoding | Optional encoding to use (defaults to UTF8 when null) |
|
static |
Reads all bytes from a stream.
src | Source stream to read from |
|
static |
Reads all bytes from a stream.
src | Source stream to read from |
|
static |
Read all content of a stream as text with utf8 encoding.
stream |
|
static |
Read all content of a stream as text with the provided encoding.
stream | |
encoding |
|
static |
Read all content of a stream as text with utf8 encoding.
stream |
|
static |
Read all content of a stream as text with the provided encoding.
stream | |
encoding |
|
static |
Read one line from the stream, encoded as utf8.
stream |
|
static |
Read one line from the stream, with the provided encoding.
stream | |
encoding |
|
static |
Reads the stream, line-for-line, with the UTF8 encoding.
stream |
|
static |
Reads the stream, line-for-line, with the UTF8 encoding. When a newline is encountered, the onNewLine func is called with the kind of line ending last encountered.
stream | |
onNewline |
|
static |
Reads the stream, line-for-line, with the provided encoding.
stream | |
encoding |
|
static |
Reads the stream, line-for-line, with the provided encoding. When a newline is encountered, the onNewLine func is called with the kind of line ending last encountered.
stream | |
encoding | |
onNewLine |
|
static |
Rewinds the current stream pointer to the beginning of the stream (when supported by the stream)
src | Source stream to rewind |
|
static |
Saves a stream to a local file.
stream | |
filePath |
|
static |
Saves a stream to a local file.
stream | |
filePath |
|
static |
Writes all given bytes to a stream.
source | Target stream to write to |
data | Binary data to write |
IOException | Thrown when the target stream is null |
|
static |
Writes all given bytes to a stream.
source | Target stream to write to |
data | Binary data to write |
IOException | Thrown when the target stream is null |
|
static |
Invokes WriteString() with the UTF8 Encoding.
stream | Stream to operate on |
data | String data to write |
|
static |
Writes a string to a stream with the provided encoding.
stream | Stream to write to |
data | String data to write |
encoding | Encoding to use |
|
static |
Invokes WriteString() with the UTF8 Encoding.
stream | Stream to operate on |
data | String data to write |
|
static |
Writes a string to a stream with the provided encoding.
stream | Stream to write to |
data | String data to write |
encoding | Encoding to use |