Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sending unsigned bytes to an outputStream socket

843790May 4 2010 — edited May 6 2010
Hi

I'm trying to send unsigned bytes to an outputStream created via a socket call,

That is,

Socket skt = new Socket(ip, port);
OutputStream out = skt.getOutputStream();

To write to this stream I'm thinking of using the out.write(byte[]) method.

The problem is that I need to send unsigned bytes but Java only has singed bytes. There are no other methods that will work. I tried using out.write(int) after reading that
this method only sends the lower 8 bits of a 32 bit integer and discards the top 24 bits. This seemed like it should work but I need to send and array of 7 bytes and there is no method such as out.write(int[]). I tried just putting it in a loop but it froze my server connection. is there an obvious way to do this that I'm missing?

Thanks in advance for any help, Mike
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2010
Added on May 4 2010
3 comments
1,107 views