Skip to main content

string-stream

string-stream System Class

Class Precedence List:

string-stream, stream, t

Description:

A string stream is a stream which reads input from or writes output to an associated string. The stream element type of a string stream is always a subtype of type character.

See Also:

make-string-input-stream, make-string-output-stream, with-input-from-string, with-output-to-string

Expanded Reference: string-stream

Overview

string-stream is the system class for streams that read from or write to strings. Both string input streams and string output streams are of this type.

Type Check for Input String Streams

(typep (make-string-input-stream "test") 'string-stream)
=> T

Type Check for Output String Streams

(typep (make-string-output-stream) 'string-stream)
=> T

Element Type is Always a Subtype of Character

(subtypep (stream-element-type (make-string-input-stream "x")) 'character)
=> T
=> T

Class Hierarchy

(subtypep 'string-stream 'stream)
=> T
=> T

Not a File Stream

String streams are distinct from file streams.

(typep (make-string-output-stream) 'file-stream)
=> NIL