i am looking for a method in java, to extract certain bytes from an input stream. for example i will have this stream of data occuring
0x01,0x02,0x00,0x01,0x00,0x01,0x03,0x04,0x00,0x01,0x09,0x08,0x00,0x01,0x00,0x01
my encoding scheme is type data ending
firstly i will check the first byte,
then i will want to store all the data in a byte array from 0x01 untill the occurance of 0x00,0x01,0x00,0x01 except for the 0x01's
so the first piece of data i would place into the array
0x01,0x02,0x00,0x00
and then onto the next ,
this begins with a 0x03 and ends with 0x00,0x01,0x00,0x01
i would like for this to be placed in another byte array as,
0x03,0x04,0x00,0x01,0x09,0x08,0x00,0x00
how would i go about doing this, i began with using
a ByteArrayOutputStream to add dynamically to the byte array, without needing to know the size, but im lost on the logic on how would extract out each pattern and remove each 0x01 following a 0x00, also im rading a byte in from an input stream , one byte at a time (its the only way i can get the bytes)