Originally posted by Ulf Dittmer:
Welcome to JavaRanch.
"new String(readBuffer)" is something to be suspicious of, because it uses the platform default encoding to convert bytes to String. Are you sure that that is the encoding used by the incoming data?
Originally posted by Ulf Dittmer:
Welcome to JavaRanch.
Also, Java assumes that incoming data is in network byte order (big endian). Is that the case here?
Are the values "132" a single byte or a stream/array of characters?
I'm wondering why you are reading 5 bytes at a time from the stream instead of single bytes. The output you show us is not all on one line. Where is the carriage return coming from? It is not in your code.
You should also have a look at our FAQ entries:
Available Doesnt Do What You Think It Does
Read Doesnt Do What You Think It Does
There's some subtle errors in your code that you'll want to fix.
As Ulf mentioned, converting bytes to Strings can be problematic. When dealing with bytes, I write out the hex value for each byte (via Integer.toHexString(int i)) to make sure I'm getting what I think I'm getting.
I understand what you mean. But how do I manage it?
Originally posted by Sven Bayer:
I got 50,13,10,49,51,50,...
Don't get me started about those stupid light bulbs. |