I'm trying to split the following: 116,24|426,776 into two strings upon the | symbol.
My code:
String[] splitString = "116,24|462,776".split("|");
System.out.println(splitString[1]);
However, this code simply returns: 1
Any clues?
You have to use escape character.
Try this String[] splitString = "116,24|462,776".split("\\|");
Here \\
is the escape character.
Please refer http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html