Java and unsigned Bytes [duplicate]
This question already has an answer here: What is the best way to work around the fact that ALL Java bytes are signed? 7 answers I need to make use of an array of unsigned bytes. I need to send certain characters over the network to a server and some of these characters are greater that 127. I have a simplified version of the code below to try and understand the concept: int i= 160; byte j = (byte) i; System.out.println((byte)i); System.out.println(j); and this gives an output of: -96 -96 I need to print 160. As the server is expecting a byte of 160 and if it receives -96 it does not accept