I want to fill in a byte array with variables at given positions.
As a minimal example, below's code tries to insert an int variable at location 10 of a byte array (which would use bytes 10,11,12 and 13 of the byte array).
public class HelloWorld{
public static void main(String []args){
// DESTIONATION BYTE ARRAY
byte[] myByteArray = new byte[64];
// INTEGER
int myInt = 542323;
// I WANT TO PUT myInt AT POSITION 10 IN myByteArray
// PSEUDOCODE BELOW:
myByteArray.putInt(myInt, 10);
}
}
I am not sure which alternatives do I have to copy an int directly to a given location of a larger byte array.