I want to split a String by delimiter "|" in Java and get the String array, here is my code:
String str = "123|sdf||";
String[] array = str.split("\\|");
I will get the array with 2 elements: "123","sdf"
.
I expect the array have 4 elements: "123","sdf","",""
;
is there any existing class I can use to do that? I also tried StringTokernizer, doesn't work