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();
DataStreambuffer, EOSMessage, stream, zerosskipBuffer| 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, writeStringArrayasInputStream, asOutputStream, asStream, asStream, skipBytes, wrapInputStream, wrapInputStreamToStream, write, writeBytes, writeBytespublic DataStreamLE(Stream stream)
stream - the base streampublic int readInt()
throws EOFException,
IOException
DataStreamreadInt in class DataStreamEOFExceptionIOExceptionpublic short readShort()
throws EOFException,
IOException
DataStreamreadShort in class DataStreamEOFExceptionIOExceptionpublic long readLong()
throws EOFException,
IOException
DataStreamreadLong in class DataStreamEOFExceptionIOExceptionpublic int readUnsignedShort()
throws EOFException,
IOException
DataStreamreadUnsignedShort in class DataStreamEOFExceptionIOExceptionDataStream.writeShort(int)public int writeInt(int i)
throws IOException
DataStreamwriteInt in class DataStreami - the integer to writeIOExceptionpublic int writeShort(int i)
throws IOException
DataStreamwriteShort in class DataStreami - the short to writeIOExceptionpublic int writeLong(long l)
throws IOException
DataStreamwriteLong in class DataStreamIOExceptionpublic char readChar()
throws EOFException,
IOException
DataStreamreadChar in class DataStreamEOFExceptionIOExceptionpublic int writeChar(char c)
throws IOException
DataStreamwriteChar in class DataStreamc - the character to be written.IOExceptionpublic void readChars(char[] chars,
int len)
throws EOFException,
IOException
readChars in class DataStreamchars - An already created chars array.len - The array length.EOFExceptionIOExceptionprotected char[] readChars(int len)
throws EOFException,
IOException
DataStreamreadChars in class DataStreamEOFExceptionIOExceptionpublic int writeChars(char[] chars,
int start,
int len,
int lenSize)
throws IOException
DataStreamwriteChars in class DataStreamIOExceptionpublic int writeChars(java.lang.String s,
int len)
throws IOException
DataStreamThe char array size is limited to 65535 characters.
writeChars in class DataStreams - 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