I need to add a length to a string which I am sending via socket connection to an external system. The format is: first 4 bytes having the length followed by data.
Should look like: 0x00, 0x00, 0x00, 0xA1, < data stream with the length of 161 characters (0xA1) >.
Doing things like: int i= 161; StringBuffer sb = new StingBuffer(); sb.insert((char)i) works up to 127. Char should be unsigned, but not supported with Java.
Any idea? Thanks.