I have a bytebuffer in java that is a mix of string and integer types, here is the code to get a better idea of what I mean.
int ID_SIZE = 8;
int LENGTH_SIZE = 8;
int MESSAGE_SIZE = 30;
char[] id = new char[ID_SIZE];
int length = 12;
String message = "\0";
for(int i = 0;i<MESSAGE_SIZE;i++)
message+="a";
ByteBuffer bbuf = ByteBuffer.allocate(35);
bbuf.putInt(length);
bbuf.put(message.getBytes());
for(int i = 0;i<36;i++)
System.out.println(bbuf.get(i));
and as the result I get
0
0
0
12
0
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
97
I know the 97 is ASCII a. However I am curious as to why before the 12 it is 0 0 0? Does this have anything to do with it being a mixed bytebuffer or is this just normal byetbuffer behavior?
000-56instead of using all 4 to sum to 150?intvalue, you wouldn't be able to store values of more than 1024.