I/O - Stream

1 - About

Stream I/O (input/output) refers to the transfer of data either to or from a storage medium. Streams are a mean to manipulate the data that is read or written from and to a file (from byte to characters, object ,…).

The file content is an ordered collection of bytes. You manipulate this sequence of byte through a stream that gives you methods to read from and write to and from destinations such as:

When you work with a file system, you work with:

  • path (directory or file),
  • disk storage,
  • name (directory or file).

Note:

3 - Asynchronous

Reading or writing a large amount of data can be resource-intensive. You should perform these tasks asynchronously if your application needs to remain responsive to the user. With synchronous I/O operations, the thread is blocked until the resource-intensive operation has completed. Use asynchronous I/O operations when developing apps to prevent creating the impression that your app has stopped working.

4 - Stream

4.1 - Data source and destination

A stream can represent many different kinds of:

  • sources
  • and destinations

that holds, generates, or consumes data.

For instance:

  • disk files,
  • another program,
  • a peripheral device,
  • or an (memory)array.

4.2 - Data Type

Typically, streams are designed for simple byte input and output but they can supports many different kinds of data including:

  • primitive data types,
  • localized characters,
  • and objects.

4.3 - Transformation

Some streams simply pass on data; others manipulate and transform the data.

4.4 - Model

All streams present the same simple model to programs that use them.

4.4.1 - Input

A program uses an input stream to read data sequentially (one item at time) from a source.

4.4.2 - Output

A program uses an output stream to write data sequentially (one item at time) to a destination.

5 - Type

5.1 - Standard

6 - Implementation

Several languages, such as Perl and Python, implement streams as iterators. Alternative implementations of stream include data-driven languages, such as AWK and sed.

7 - Documentation / Reference

io/stream.txt · Last modified: 2017/10/08 13:17 by gerardnico