I'm trying to duplicate a byte String that I produce in Objective-C (on iOS) in Java but am having trouble. Here's the string I want to produce:
"\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
I get that string from an array of 4 integers - [1,1,0,0] - where each integer has 4 bytes. After looking at a bunch of questions on here, I've attempted constructing that string in Java using ByteBuffer as follows:
ByteBuffer bytes = ByteBuffer.allocate(16);
bytes.putInt(1);
bytes.putInt(1);
bytes.putInt(0);
bytes.putInt(0);
String byteString = new String(bytes.array());
However that gives me:
"\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
When I unpack that, the array of ints I get is [16777216, 16777216, 0, 0]. Obviously I'm doing something wrong, and I'm hoping someone can point me in the right direction.