I have a String that I have to concatenate with an byte array, so I tried this
String msg = "msg to show";
byte[] msgByte = new byte[msg.length()];
try {
msgByte = msg.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] command = {2,5,1,5}
byte[] c = new byte[msgByte.length + command.length];
System.arraycopy(command, 0, c, 0, command.length);
System.arraycopy(msjByte, 0, c, command.length, msjByte.length);
for(Byte bt:c)
System.out.println(bt+"");
This is the output:
2 5 1 5 109 115 103 32 ...
but the result that I'm looking for is this
2 5 1 5 m s g ...
I need it in one array cause it's used as a command for a bluetooth printer.
Is there a way, any suggestions?
Thanks in advance! :)