Posted By:
Edward_Hopper
Posted On:
Sunday, June 18, 2006 07:57 AM
Hi, I get from an archive-server via http a string with archive-data(legacy-system). The smallest part of a string is char (charAt(y)). char is 2 Byte long and byte in 1 Byte long. In java a byte has the range from -128 to 127. In the return-String from the server are values greater than 127. For example 192. So, if I cast the char "192" to byte --> information get lossed. I emphasize that I do not have a problem to cast. The program works but the output is "wrong - in the sense - that a byte can't hold a value greater than 127. In other languages like C you have an unsigned byte ( 0 to 255 ). But not in Java.
More>>
Hi,
I get from an archive-server via http a string with archive-data(legacy-system).
The smallest part of a string is char (charAt(y)). char is 2 Byte long and byte in 1 Byte long. In java a byte has the range from -128 to 127.
In the return-String from the server are values greater than 127. For example 192.
So, if I cast the char "192" to byte --> information get lossed. I emphasize that I do not have a problem to cast. The program works but the output is "wrong - in the sense - that a byte can't hold a value greater than 127.
In other languages like C you have an unsigned byte ( 0 to 255 ). But not in Java.
Is that problem soluble in Java?
How can I convert the string to an byte-array or the single char to a byte if a java-byte is always signed.
I assume that my java-thinking is wrong!!!???
For me it is inconceivable that java is not able to solve such a "daily" problem.
I am grateful to get a lot of hints and examples. Please!
Thank you and
kind regards
edho
<<Less