String input = "a,b,c"; String[] output = StringUtils.splitPreserveAllTokens(input, ","); // output = {"a", "b", "c"}
String input = "a,,b,"; String[] output = StringUtils.splitPreserveAllTokens(input, ","); // output = {"a", "", "b", ""}
String input = "a\t\tb\tc"; String[] output = StringUtils.splitPreserveAllTokens(input, "\t"); // output = {"a", "", "b", "c"}This example splits the string "a\t\tb\tc" by the tab delimiter, and preserves the empty tokens between the consecutive tabs. To use the StringUtils class and its methods, you need to add the commons-lang3-x.x.jar library to your project's classpath.