List of utility methods to do String Split by Space
List | splitStringOnWhitespace(String text) Split the given String on whitespace characters. List elements = new ArrayList(); StringBuffer buffer = new StringBuffer(); char[] chars = text.toCharArray(); for (int i = 0; i < chars.length; i++) { if (Character.isWhitespace(chars[i])) { if (buffer.length() > 0) { elements.add(buffer.toString()); buffer = new StringBuffer(); ... |
String[] | splitWithoutWhitespace(String source, String separator) split Without Whitespace List<String> result = new ArrayList<String>(); String[] items = source.split(separator); for (String s : items) { if (!"".equals(s.trim())) { result.add(s.trim()); return result.toArray(new String[result.size()]); ... |
Collection | whitespaceSplit(final String input) whitespace Split if (input == null) { return Collections.emptyList(); final String[] splitValues = input.trim().split("\\s+"); return Arrays.asList(splitValues); |