I got a byte array sent from javascript by ajax looking like this:
"89,50,4e,47,0d,0a,1a,0a,00,00,00,0d,49,48,44,52,00,00,01,98,00,00,00,e4,08,06,00 ..."
I would like to convert this string to a byte array. Pretty similar to this question, but using Java instead: Convert String[] to byte[] array
Edit: This seems to work - but not sure if i am doing it right
String[] byteData ="89,50,4e,47,0d,0a,1a,0a,00,00,00,0d,49,48,44,52,00,00,01,98,00,00,00,e4,08,06,00";
byte[] b = new byte[byteData.length];
for (int i = 0; i < byteData.length; i++) {
BigInteger bla = BigInteger.valueOf(Integer.parseInt(byteData[i].trim(), 16) - 128);
b[i] = bla.toByteArray()[0];
}