Split a string with the specified delimiter without omitting empty elements.
Use the org.apache.commons.lang.StringUtils.splitByWholeSeparatorPreserveAllTokens() method
Advantage over another method of another class:
- It does not skip any substring or empty string and works fine for all char or string as a separator.
- It also has a polymorphic form, where we can specify the maximum number of tokens expected from a given string.
String.Split() method accepts regex as a parameter, so it will work for some character as a separator, but not for all, for example: pipe (|), etc. We need to add an escape char to pipe (|) so that it works fine.
Tokenizer (String or stream) - it skips an empty string between delimiter's .
Setu poddar
source share