Navigation:  Programming Cookbook > Binary Filing Objects >

Storing objects

Previous pageReturn to chapter overviewNext page

When objects are stored they include any objects contained within their named and indexed instance variables. The translation to the compact binary format is performed by an instance of STBOutFiler. This routes its output via an attached, binary-aware stream which you must create first (this is typically a writeable FileStream in byte mode). Once the STBOutFiler is instantiated on the stream, objects can be output using the filer's #nextPut: method.

S := FileStream write:'Test.STB' text: false.

(STBOutFiler on: S)

  nextPut: X;

  nextPut: Y;

  nextPut: Z.

S close.


To store the objects to a ByteArray rather than a file, simply replace the binary-aware FileStream with a WriteStream on a ByteArray.