I am using String.split()
to split a string. The string I receive has this structure:
[data]<US>[data]<US>
where <US>
is the ASCII unit separator (code 0x1F). The code to split is
String[] fields = someString.split(String.valueOf(0x1f));
This works fine, unless [DATA]
is an empty string. In that case, data just gets skipped.
I want a string like [DATA]<US><US>[DATA]<US>
to return an array with three elements: [DATA]
, null
and [DATA]
.
How can I do that?