byte-streams
The byte-streams
module provides streams for reading and writing bytes.
API Reference
Classes
ByteReader
Constructors
ByteReader(inputStream)
Creates a binary input stream that reads bytes from a backing stream.
The backing stream, an nsIInputStream
.
Methods
close()
Closes both the stream and its backing stream. If the stream is already closed, an exception is thrown.
read(numBytes)
Reads a string from the stream. If the stream is closed, an exception is thrown.
The number of bytes to read. If not given, the remainder of the entire stream is read.
A string containing the bytes read. If the stream is at the end, returns the empty string.
Properties
closed : boolean
True if the stream is closed.
ByteWriter
Constructors
ByteWriter(outputStream)
Creates a binary output stream that writes bytes to a backing stream.
The backing stream, an nsIOutputStream
.
Methods
close()
Closes both the stream and its backing stream. If the stream is already closed, an exception is thrown.
write(str)
Writes a string to the stream. If the stream is closed, an exception is thrown.
The string to write.
Properties
closed : boolean
True if the stream is closed.