Java Experts ,
Please look into the below split command code and let me know why last two nulls are not captured.
String test = \"1,O1,,,,0.0000,0.0000,
split
silently discards trailing separators, as specified in the Javadoc.
In general, the behavior of split
is kind of weird. Consider using Guava's Splitter instead, which has somewhat more predictable and customizable behavior. (Disclosure: I contribute to Guava.)
Splitter.on(',').split("1,O1,,,,0.0000,0.0000,,");
// returns [1, O1, , , , 0.0000, 0.0000, , ]
Splitter.on(',').omitEmptyStrings()
.split("1,O1,,,,0.0000,0.0000,,");
// returns [1, O1, 0.0000, 0.0000]