I am trying to convert String array to Byte array and then to string using following code.
It is working fine when byte is in between -128 to 127, but i am trying to convert larger than 127 when byte is in between 0 to 256 (like 133 or 155 etc.,) getting error like:
java.lang.NumberFormatException: Value out of range. value:"133"
String response = "[-47, 1, 16, 84, 2, 101, 110, 83, 111, 109, 101, 32, 78, 70, 67, 32, 68, 97]";
String[] byteValues = response.substring(1, response.length() - 1).split(",");
byte[] bytes = new byte[byteValues.length];
for (int i=0, len=bytes.length; i<len; i++) {
bytes[i] = Byte.valueof(byteValues[i].trim());
}
String str = new String(bytes);
Any help?!