According to the documentation :
This method works as if a separation method with two arguments with a given expression and a limit argument of zero.
To split up with a marginal argument, he says:
If n is not positive, then the pattern will be applied as many times as possible, and the array can be of any length. If n is zero, then the template will be applied as many times as possible, the array can be of any length and the final empty lines will be discarded.
So, try calling the split method with a non-positive limit argument, for example:
String[] pieces = s.split(":", -1);
Alex
source share