Created
August 6, 2017 13:08
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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