|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
totalcross.lang.Objecttotalcross.io.Stream
totalcross.io.DataStream
totalcross.io.DataStreamLE
public class DataStreamLE
DataStreamLE can be attached to any Stream such as a PortConnector, PDBFile, or ByteArrayStream, which lets you read and write standard Java data types like int, double, and totalcross.lang.String in a simple manner. Here's an example:
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| Field Summary |
|---|
| Fields inherited from class totalcross.io.DataStream |
|---|
buffer, EOSMessage, stream, zeros |
| Fields inherited from class totalcross.io.Stream |
|---|
skipBuffer |
| Constructor Summary | |
|---|---|
DataStreamLE(Stream stream)
Constructs a new DataStreamLE which sits upon the given stream using litle endian notation for multibyte values. |
|
| Method Summary | |
|---|---|
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(String s,
int len)
Writes the totalcross.lang.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. |
| Methods inherited from class totalcross.io.DataStream |
|---|
close, getStream, pad, readBigChars, readBigString, readBoolean, readByte, readBytes, readBytes, readBytesInternal, readChars, readChars, readCString, readDouble, readFixedString, readFloat, readObject, readSmallString, readString, readStringArray, readUnsignedByte, skip, writeBigChars, writeBigString, writeBoolean, writeByte, writeByte, writeBytes, writeBytes, writeBytes, writeChars, writeCString, writeDouble, writeFixedString, writeFixedString, writeFloat, writeObject, writeSmallString, writeString, writeStringArray |
| Methods inherited from class totalcross.io.Stream |
|---|
skipBytes |
| Methods inherited from class totalcross.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DataStreamLE(Stream stream)
stream - the base stream| Method Detail |
|---|
public int readInt()
throws IOException
DataStream
readInt in class DataStreamIOException
public short readShort()
throws IOException
DataStream
readShort in class DataStreamIOException
public long readLong()
throws IOException
DataStream
readLong in class DataStreamIOException
public int readUnsignedShort()
throws IOException
DataStream
readUnsignedShort in class DataStreamIOExceptionDataStream.writeShort(int)
public int writeInt(int i)
throws IOException
DataStream
writeInt in class DataStreami - the integer to write
IOException
public int writeShort(int i)
throws IOException
DataStream
writeShort in class DataStreami - the short to write
IOException
public int writeLong(long l)
throws IOException
DataStream
writeLong in class DataStreamIOException
public char readChar()
throws IOException
DataStream
readChar in class DataStreamIOException
public int writeChar(char c)
throws IOException
DataStream
writeChar in class DataStreamc - the character to be written.
IOException
public void readChars(char[] chars,
int len)
throws IOException
readChars in class DataStreamchars - An already created chars array.len - The array length.
IOException
protected char[] readChars(int len)
throws IOException
DataStream
readChars in class DataStreamIOException
public int writeChars(char[] chars,
int start,
int len,
int lenSize)
throws IOException
DataStream
writeChars in class DataStreamIOException
public int writeChars(String s,
int len)
throws IOException
DataStreamThe char array size is limited to 65535 characters.
writeChars in class DataStreams - The totalcross.lang.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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||