I’m writing an application where I’m receiving a message that is a sequence of tag1=value1|tag2=value2|tag3=value3 etc. I want to split it around the | delimiter.
Having read the Javadoc there is nothing to say that the String.split(String regex) method is guaranteed to maintain the original order of the message. I’ve played about and it seems ok, but I’d rather not commit to this approach if I’m going to get caught out later.
So, does anybody know if there are any situations where the order of array elements returned by split() can be altered from the original String? Or can anyone point out any documentation that says the order is guaranteed to be maintained?
(Apologies if this is a dupe, but I can’t find a similar question on the site.)
The javadoc says:
EDIT: the above is for the two-argument
split(String regex, int limit)version, but the single-argument version