Try the following:
String[] = "abcde|12345|xyz".split("|");
The results will not be as (at least I..) anticipated.
Using any other character seems to be ok.
String[] = "abcde,12345,xyz".split(",");
So what is special with the pipe?
Try the following:
String[] = "abcde|12345|xyz".split("|");
The results will not be as (at least I..) anticipated.
Using any other character seems to be ok.
String[] = "abcde,12345,xyz".split(",");
So what is special with the pipe?
Java String.split() expects a RegExp and the pipe character has special meaning in RegExps other than a comma. Try the following:
String[] = "abcde|12345|xyz".split("\\|");
The split
method is expecting a regular expression, and "|" is a special character in regex world: http://www.tutorialspoint.com/java/java_string_split.htm