I have a string as follows:
'mnp1011000jie'
I want to retrieve contents of the string as follows:
1st field: mnp
2nd field: 101 (which signifies the binary representation of 5)
3rd field: 1000 (which signifies the binary representation of 8)
4th field: jie
I know that binary integer requires 4 bytes of storage.String considers one byte of storage for each character. Just retrieving 4 bytes from 'mnp' onwards will give 1011 which is a mess up of two distinct binary integers stored side by side.
The main problem is that I am not able to retrieve the two consecutive binary numbers stored in a string.How can I proceed bytewise to extract the two consecutive binary numbers?
Pattern Matching classes are not proving useful in this case.If I use these classes,then I get an output as follows:
1 0 1 1 0 0 0
which is not the expected output.
The expected output is:
1st field: mnp
2nd field: 101 (which signifies the binary representation of 5)
3rd field: 1000 (which signifies the binary representation of 8)
4th field: jie
How can I do this USING CORE JAVA?