| Author |
Read/Write ints using 2bytes
|
Lora Tully
Greenhorn
Joined: Nov 29, 2004
Posts: 8
|
|
Hi. I was wondering if anyone can help me read and write one interger using two bytes. I have an interger between 500-800 that I need to write. Normally I would use... OUT.writeByte(int) But as 500 is above one byte (256) I was wondering how to write this, and then later read it back. As since one int would be spread over two bytes, I have no idea how to read it, normally I would use IN.readByte() And I have no idea how to do this. Can anyone help me please?
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
|
Try DataOutputStream.writeShort() and DataInputStream.readShort()
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
Lora Tully
Greenhorn
Joined: Nov 29, 2004
Posts: 8
|
|
|
Thanks that works great!
|
 |
 |
|
|
subject: Read/Write ints using 2bytes
|
|
|