The IDataOutput interface provides a set of methods for writing binary data. This interface is the I/O counterpart to the IDataInput interface, which reads binary data. The IDataOutput interface is implemented by the FileStream, Socket and ByteArray classes.

All IDataInput and IDataOutput operations are "bigEndian" by default (the most significant byte in the sequence is stored at the lowest or first storage address), and are nonblocking.

Sign extension matters only when you read data, not when you write it. Therefore, you do not need separate write methods to work with IDataInput.readUnsignedByte() and IDataInput.readUnsignedShort(). In other words:

Variables

endian:Endian

The byte order for the data, either the BIG_ENDIAN or LITTLE_ENDIAN constant from the Endian class.

objectEncoding:ObjectEncoding

Used to determine whether the AMF3 or AMF0 format is used when writing or reading binary data using the writeObject() method. The value is a constant from the ObjectEncoding class.

Methods

writeBoolean(value:Bool):Void

Writes a Boolean value. A single byte is written according to the value parameter, either 1 if true or 0 if false.

Parameters:

value

A Boolean value determining which byte is written. If the parameter is true, 1 is written; if false, 0 is written.

writeByte(value:Int):Void

Writes a byte. The low 8 bits of the parameter are used; the high 24 bits are ignored.

Parameters:

value

A byte value as an integer.

@:value({ length : 0, offset : 0 })writeBytes(bytes:ByteArray, offset:Int = 0, length:Int = 0):Void

Writes a sequence of bytes from the specified byte array, bytes, starting at the byte specified by offset (using a zero-based index) with a length specified by length, into the file stream, byte stream, or byte array.

If the length parameter is omitted, the default length of 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written.

If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array.

Parameters:

bytes

The byte array to write.

offset

A zero-based index specifying the position into the array to begin writing.

length

An unsigned integer specifying how far into the buffer to write.

writeDouble(value:Float):Void

Writes an IEEE 754 double-precision (64-bit) floating point number.

Parameters:

value

A double-precision (64-bit) floating point number.

writeFloat(value:Float):Void

Writes an IEEE 754 single-precision (32-bit) floating point number.

Parameters:

value

A single-precision (32-bit) floating point number.

writeInt(value:Int):Void

Writes a 32-bit signed integer.

Parameters:

value

A byte value as a signed integer.

writeMultiByte(value:String, charSet:String):Void

Writes a multibyte string to the file stream, byte stream, or byte array, using the specified character set.

Parameters:

value

The string value to be written.

charSet

The string denoting the character set to use. Possible character set strings include "shift-jis", "cn-gb", "iso-8859-1", and others. For a complete list, see Supported Character Sets.

writeObject(object:Dynamic):Void

Writes an object to the file stream, byte stream, or byte array, in AMF serialized format.

Parameters:

object

The object to be serialized.

writeShort(value:Int):Void

Writes a 16-bit integer. The low 16 bits of the parameter are used; the high 16 bits are ignored.

Parameters:

value

A byte value as an integer.

writeUTF(value:String):Void

Writes a UTF-8 string to the file stream, byte stream, or byte array. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string.

Parameters:

value

The string value to be written.

Throws:

RangeError

If the length is larger than 65535.

writeUTFBytes(value:String):Void

Writes a UTF-8 string. Similar to writeUTF(), but does not prefix the string with a 16-bit length word.

Parameters:

value

The string value to be written.

writeUnsignedInt(value:Int):Void

Writes a 32-bit unsigned integer.

Parameters:

value

A byte value as an unsigned integer.