I have a serial communication protocol and I am receiving messages all the time and the messages arrive in an array almost all at the same time and I would like to separate this array into several others using the characters that determine the beginning [ 102] [102] and stopping at the characters that indicate the end of the message [50] [101], how could you do this?
I tried as follows:
byte[] buffer = Arrays.copyOfRange(dados,0,16);
byte[] buffer1 = Arrays.copyOfRange(dados,16,32);
byte[] buffer2 = Arrays.copyOfRange(dados, 32, 48);
however, if I stop receiving the message from any of my equipment, the main array changes, generating an exception