I want to split the string into delimiter "|" in Java and get an array of String, here is my code:
String str = "123|sdf||";
String[] array = str.split("\\|");
I'll get an array with two elements: "123","sdf". I expect the array has 4 elements "123","sdf","","":; Is there any existing class that I can use for this? I also tried StringTokernizer, not working
source
share