This content has been marked as final. Show 4 replies
1 person found this helpful
Jorg3 wrote:No it's not. It's printing decimal values.
because the Java application is printing hexadecimal values instead octal ones.
You can print out octal values with printf for example.
Well I didn't express myself properly, sorry. What I mean is that the values it prints are decimal but they're over 2^15 (they don't go over 2^16), while in PHP and in all other places in the Java application where I've tried my method they don't go over 2^8. And I can't understand why is that happening if my method works fine on the rest of the code.
You receive a stream of bytes and you want to dispay their values. You expect them to show as 0, 1 etc up to 255. These bytes are not text. The conversion to string is unnecessary and dangereous. Work with byte all the way. The converion of bytes to string may result, randomly, in values that are represented by characters whose values are above 255. It can also result in loss of data, if a 'character' received does not map to an actual character in your platform encoding.
Edited by: baftos on Dec 7, 2012 9:45 AM
Okay that seems to work. Doesn't really solve my original problem because I keep receiving different replies to same request, but well it solves the question in this thread, so I guess I gotta mark it as solved. Thanks.