Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

DataStream contains DataInput and DataOutput, which can read or write binary data from any InputStream? or OutputStream?.

Supported types

Following types are supported by DataStream:

D typeDataInput methodDataOutput method
boolgetBoolputBool
bytegetByteputByte
shortgetShortputShort
intgetIntputInt
longgetLongputLong
floatgetFloatputFloat
doublegetDoubleputDouble
void[]getput

Using a cast, there's also support for ubyte, ushort, uint, ulong, char (using byte), wchar (using short), dchar (using int) and arrays of those, although array elements aren't swapped even if flip is true (see Byte order). This does not apply to char[], byte[] and ubyte[], whose elements are byte order neutral.

Data format

A void[] is written with the number of elements as written by putInt and the array content as it is in memory.

Byte order

Unless otherwise specified, output is written in host byte order and input is assumed to be in host byte order. To reverse the byte order, use the constructor with the flip parameter. To always read or write one specific byte order, the host byte order must be determined and flip must be set accordingly.