Class MemoryOutputStream
└
Object
An OutputStream
which stores the data written to it in a memory buffer.
- Source Code:
- View Source
Initializer Summary
init ()- Creates a new
MemoryOutputStream
. init (capacity :
)Int - Creates a new
MemoryOutputStream
with the specified capacity.
Inherited Fields:
Instance Method Summary
write (i :
):UInt8 Error? - Writes a single byte.
write (ptr :
,Pointer<UInt8> count :
):Int Error? - Writes a block of data to this stream.
clear ()- Clears all data written to the stream.
finish ():String - Invalidates this stream and returns its contents as an immutable
String
.
Inherited Methods:
close():Error?
flush():Error?
printLine():Error?
printLine(Object):Error?
printLine(String):Error?
print(Object):Error?
print(String):Error?
write(Char8):Error?
write(Array<Char8>, Int):Error?
write(Array<Int8>, Int):Error?
write(Array<UInt8>, Int):Error?
write(Pointer<Char8>, Int):Error?
write(Pointer<Int8>, Int):Error?
write(Int64):Error?
write(Int32):Error?
write(Int16):Error?
write(Int8):Error?
write(UInt64):Error?
write(UInt32):Error?
write(UInt16):Error?
Initializers
init
()
Creates a new MemoryOutputStream
.
init
(capacity :Int
)
Creates a new MemoryOutputStream
with the specified capacity.
- Parameters:
-
- value of typecapacity Int
Instance Methods
@override
method write
(ptr :Pointer<UInt8>
,
count :Int
):Error?
Writes a block of data to this stream.
- Parameters:
-
-ptr Pointer to the data to write
-count number of bytes to write
- Overrides:
- frost.io.OutputStream.write
method clear
()
Clears all data written to the stream.
method finish
():String
Invalidates this stream and returns its contents as an immutable String
. This is generally
preferable to toString
, as it does not copy the stream's contents. Interacting in any way
with a MemoryOutputStream
after finish
ing it will cause precondition violations (or, if
safety checks are disabled, undefined behavior).