superwaba.ext.xplat.io
Class DataStream
java.lang.Object
|
+--waba.io.Stream
|
+--waba.io.DataStream
|
+--superwaba.ext.xplat.io.DataStream
- public class DataStream
- extends DataStream
DataStream is a wrapper you can place around any Stream such as a
SerialPort, Catalog, or BufferStream which lets you read and write
standard Waba data types like ints, floats, and Strings in a simple
manner. Here's an example
SerialPort port=new SerialPort(9600,0);
DataStream ds=new DataStream(port);
ds.writeString("Hello");
int status=ds.readUnsignedByte();
if (status==1)
{
ds.writeString("Pi");
ds.writeFloat(3.14);
}
port.close();
Constructor Summary |
DataStream(Stream stream)
Constructs a new DataStream which sits upon the given stream using
the big endian notation for multibyte values. |
Methods inherited from class waba.io.DataStream |
close,
isOpen,
pad,
readBoolean,
readByte,
readBytes,
readBytes,
readChars,
readDouble,
readFloat,
readInt,
readIntLE,
readLong,
readShort,
readShortLE,
readString,
readStringArray,
readUnsignedByte,
readUnsignedShort,
skip,
writeBoolean,
writeByte,
writeByte,
writeBytes,
writeBytes,
writeChars,
writeCString,
writeDouble,
writeFloat,
writeInt,
writeIntLE,
writeLong,
writeShort,
writeShortLE,
writeString,
writeStringArray |
DataStream
public DataStream(Stream stream)
- Constructs a new DataStream which sits upon the given stream using
the big endian notation for multibyte values.
- Parameters:
stream
- the base stream
readCString
public String readCString()
- Reads a C-style string from the stream. This is a NUL (0) terminated
series of characters. This format is commonly used by other Palm
applications.
- Overrides:
- readCString in class DataStream
- Returns:
- the loaded String
readFixedString
public String readFixedString(int length)
- Reads a fixed length string from the stream. The given number of
characters are read and converted to a String.
- Parameters:
length
- the number of characters to read- Returns:
- the loaded string
writeFixedString
public void writeFixedString(String s,
int length)
- Writes a fixed length string to the stream. If the given string is
longer than the given length, it will be truncated and if it is shorter,
it will be padded with spaces.
- Parameters:
s
- the string to writelength
- the length of the fixed string
writeFixedString
public void writeFixedString(String s,
int length,
char pad)
- Writes a fixed length string to the stream. If the given string is
longer than the given length, it will be truncated and if it is shorter,
it will be padded the given pad character.
- Parameters:
s
- the string to writelength
- the length of the fixed stringthe
- character to pad if the string is shorter than the length