Streams offer a better way than collections to incrementally read and write a sequence of elements. There are easy ways to convert back and forth between streams and collections.
- Streams may be either readable, writeable or both readable and writeable.
- To convert a collection to a stream, define a stream “on” a collection, e.g.,
ReadStream on: (1 to: 1000), or send the messages
readStream, etc. to the collection.
- To convert a stream to a collection, send the message
- To concatenate large collections, instead of using the comma operator, it is more efficient to create a stream, append the collections to the stream with
nextPutAll:, and extract the result by sending
- File streams are by default character-based. Send
binaryto explicitly make them binary.