I need a little explanation of how can I do something in Java / Android. I need to construct a byte array / data packet so I can send it via http request. I need it to look like this :
- 3 bytes reserved (zero padded)
- 1 byte - Operation Group
- 1 byte - Packet type
- the rest depends on the above
But I don't know how can I construct byte[] like this.
Here is what I've tried :
String padding = "0000000000"; // first part of packet
String group = "0xA"; // second part of packet
String type = "02"; // third part of packet
String content = "ThisIsATestStringWhichYouWillReadButItsADumbAssStringDudeSorryForYou"; // last part of packet
String wholePacket = padding.concat(group.concat(type.concat(content)));
Log.v("","wholePacket : "+wholePacket);
byte[] bytes = EncodingUtils.getBytes(wholePacket, "UTF-8");
Any suggestions?
paddingis 10 bytes length, how does this cope with the spec? (3 bytes) And what is wrong with what you wrote - I don't see a question here.