Monday, August 15, 2016

Stream

Stream
is an abstract class that transfer bytes (read, write, etc.) to the source. 
It is like a wrapper class to transfer bytes. 
Classes that need to read/write bytes from a particular source must implement the Stream class.

FileStream
reads or writes bytes from/to a physical file whether it is a .txt, .exe, .jpg or any other file.

MemoryStream
reads or writes bytes that are stored in memory.

BufferedStream
reads or writes bytes from other Streams to improve the performance of certain I/O operations.

NetworkStream
reads or writes bytes from a network socket.

PipeStream
reads or writes bytes from different processes.

CryptoStream
is for linking data streams to cryptographic transformations.


FileStream writes bytes, StreamWriter writes text

Readers and Writers:

StreamReader
is a helper class for reading characters from a Stream by converting bytes into characters using an encoded value. It can be used to read strings (characters) from different Streams like FileStream, MemoryStream, etc.

StreamWriter
is a helper class for writing a string to a Stream by converting characters into bytes. It can be used to write strings to different Streams such as FileStream, MemoryStream, etc.

BinaryReader
is a helper class for reading primitive datatype from bytes.

BinaryWriter
writes primitive types in binary.

No comments:

Post a Comment