Tokenizing a string with HEX characters
I am trying to tokenize a string that contains non-displayable characters i.e. HEX. How to split a string based on some HEX characters. e.g.
Here represents any HEX character which I want to to set as part of Token along with some string as a Token. can be any HEX character but I just want to split on some of them e.g. in the following sample string I want to split at TEST2
Code:
"StartTEST1TEST2TEST3TEST2TEST4TEST5TEST6TEST2TEST7TEST812END"
based on my Tokens the output should look as below:
Code:
StartTEST1
TEST3
TEST4TEST5TEST6
TEST7TEST812END
Any idea how to do this. Any help is appreciated.
Thanks
Re: Tokenizing a string with HEX characters
try it using the class StringTokenizer
Re: Tokenizing a string with HEX characters
The StringTokenizer class is deprecated. The canonical way of splitting strings is to use String.split(...) which uses a regular expression to break the string into an array of substrings.
The Pattern class documents how to develop a regular expression, and shows how hex values can be used.
The greatest obstacle to discovery is not ignorance, but the illusion of knowledge...
D. Boorstin