split
uses regular expressions (unfortunately IMO). ^
is of particular importance in regular expressions, so you need to avoid it:
String[] bits = readBuf.split("\\^");
(The first backslash is needed to escape Java. The actual line is just one backslash and caret.)
Alternatively, use the Guava and Splitter
class.
source share