Reading the contents of a stream message is similar to reading from a data stream, using the access methods shown in Table 2–21: for example, the statement
int intVal = inMsg.readInt();
retrieves an integer value from the message stream.
Table 2–21 Stream Message Access Methods
Name |
Description |
---|---|
Read integer from message stream |
|
Read byte value from message stream |
|
Read byte array from message stream |
|
Read short integer from message stream |
|
Read long integer from message stream |
|
Read floating-point value from message stream |
|
Read double-precision value from message stream |
|
Read boolean value from message stream |
|
Read character from message stream |
|
Read string from message stream |
|
Read value from message stream as object |
The readObject method returns the next value from the message stream in objectified form, as a Java object of the class corresponding to the value’s primitive data type: for instance, if the value is of type int, readObject returns an object of class Integer. The following statements are equivalent to the one shown above:
Integer intObject = (Integer) inMsg.readObject(); int intVal = intObject.intValue();