BinaryWriter.kl

Types

BinaryWriter (object)

バージョン 1.12.0 で追加.

The BinaryWriter is used to write binary data to files. It supports writing of any shallow data structure represented as a Data pointer and a DataSize.

/*
** Example: BinaryWriter
*/

require FileIO;
  
operator entry() {

      FilePath path = FilePath('${TEMP}/binaryWriter.bin').expandEnvVars();
      {
        BinaryWriter writer = BinaryWriter(path.string());
        Size count = 50;
        Scalar values[];
        values.resize(count);
        for(Size i=0;i<values.size();i++)
          values[i] = Scalar(i) * 0.7;
        report(values[3]);
        report(values[17]);
        report(values[33]);
      
        writer.write(count.data(), count.dataSize());
        writer.write(values.data(), values.dataSize());
        report('Binary file written.');
      }
  
}

/*
** Output:

+2.1
+11.9
+23.1
Binary file written.

*/

Methods

  BinaryWriter ( in BinaryWriter other )
  BinaryWriter ( in String filePath )
  BinaryWriter ()
BinaryWriter clone ? ()
Boolean close ! ()
Boolean isOpen ? ()
Boolean open ! ( in String filePath )
UInt64 pos ! ()
  seek ! ( in UInt64 pos )
  write ! ( in Data data, in UInt64 dataSize )
  writeString ! ( in String string )
  writeStringArray ! ( in String strings[] )
  ~BinaryWriter ()