public class DataStreamLE extends DataStream
PortConnector port = new PortConnector(9600, 0); DataStream ds = new DataStream(port); ds.writeString("Hello"); int status = ds.readUnsignedByte(); if (status == 1) { ds.writeString("Pi"); ds.writeDouble(3.14); } port.close();
DataStream
buffer, EOSMessage, stream, zeros
skipBuffer
Constructor and Description |
---|
DataStreamLE(Stream stream)
Constructs a new DataStreamLE which sits upon the given stream using litle
endian notation for multibyte values.
|
Modifier and Type | Method and Description |
---|---|
char |
readChar()
Reads a two-byte character.
|
void |
readChars(char[] chars,
int len)
Reads a char array with the given length.
|
protected char[] |
readChars(int len)
Reads a char array with the given length.
|
int |
readInt()
Reads an integer from the stream as four bytes.
|
long |
readLong()
Reads a long.
|
short |
readShort()
Reads a short from the stream as two bytes.
|
int |
readUnsignedShort()
Reads an unsigned short from the stream as two bytes.
|
int |
writeChar(char c)
Writes a two-byte character.
|
int |
writeChars(char[] chars,
int start,
int len,
int lenSize)
Writes the given char array, writting the length as an int or as a short or as a byte or don't
writting the length, depending on the number of bytes given (4,2,1,0).
|
int |
writeChars(java.lang.String s,
int len)
Writes the String as a char array.
|
int |
writeInt(int i)
Writes an integer to the stream as four bytes.
|
int |
writeLong(long l)
Writes a long.
|
int |
writeShort(int i)
Writes a short to the stream as two bytes.
|
close, getStream, pad, readBigChars, readBigString, readBoolean, readByte, readBytes, readBytes, readBytesInternal, readChars, readChars, readCString, readDouble, readFixedString, readFloat, readObject, readSmallString, readString, readStringArray, readStringArray, readUnsignedByte, readUnsignedInt, skip, writeBigChars, writeBigString, writeBoolean, writeByte, writeByte, writeBytes, writeBytes, writeBytesInternal, writeChars, writeCString, writeDouble, writeFixedString, writeFixedString, writeFloat, writeObject, writeSmallString, writeSmallString8, writeString, writeStringArray
asInputStream, asOutputStream, asStream, asStream, skipBytes, wrapInputStream, wrapInputStreamToStream, write, writeBytes, writeBytes
public DataStreamLE(Stream stream)
stream
- the base streampublic int readInt() throws EOFException, IOException
DataStream
readInt
in class DataStream
EOFException
IOException
public short readShort() throws EOFException, IOException
DataStream
readShort
in class DataStream
EOFException
IOException
public long readLong() throws EOFException, IOException
DataStream
readLong
in class DataStream
EOFException
IOException
public int readUnsignedShort() throws EOFException, IOException
DataStream
readUnsignedShort
in class DataStream
EOFException
IOException
DataStream.writeShort(int)
public int writeInt(int i) throws IOException
DataStream
writeInt
in class DataStream
i
- the integer to writeIOException
public int writeShort(int i) throws IOException
DataStream
writeShort
in class DataStream
i
- the short to writeIOException
public int writeLong(long l) throws IOException
DataStream
writeLong
in class DataStream
IOException
public char readChar() throws EOFException, IOException
DataStream
readChar
in class DataStream
EOFException
IOException
public int writeChar(char c) throws IOException
DataStream
writeChar
in class DataStream
c
- the character to be written.IOException
public void readChars(char[] chars, int len) throws EOFException, IOException
readChars
in class DataStream
chars
- An already created chars array.len
- The array length.EOFException
IOException
protected char[] readChars(int len) throws EOFException, IOException
DataStream
readChars
in class DataStream
EOFException
IOException
public int writeChars(char[] chars, int start, int len, int lenSize) throws IOException
DataStream
writeChars
in class DataStream
IOException
public int writeChars(java.lang.String s, int len) throws IOException
DataStream
The char array size is limited to 65535 characters.
writeChars
in class DataStream
s
- The String to be written. Must not be null!len
- The maximum number of chars to be written. Must be less than the String's length.IOException