Skip to content

Instantly share code, notes, and snippets.

@dashaw92
Created August 6, 2017 13:08
Show Gist options
  • Save dashaw92/42afdeca996ecf2ae7dd5abeb9e8208d to your computer and use it in GitHub Desktop.
Save dashaw92/42afdeca996ecf2ae7dd5abeb9e8208d to your computer and use it in GitHub Desktop.
Create a byte array where every value is followed by a 0x00
//this is for https://github.com/dashaw92/500IQIdea
private static byte[] construct(String msg) {
byte[] packet = new byte[(2 + msg.length()) * 2];
packet[0] = 0x03;
packet[2] = (byte)msg.length();
for(int i = 0; i < msg.length(); i++) {
packet[4 + (i * 2)] = (byte)msg.charAt(i);
}
return packet;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment