@Test public void testSplit() throws Exception { assertArrayEquals(ss("John", "Doe"), StringUtils.split("John Doe", ' ')); assertArrayEquals(ss("John", "", "Doe", ""), StringUtils.split("John Doe ", ' ')); assertArrayEquals(ss("", "John", "Doe", ""), StringUtils.split(" John Doe ", ' ')); assertArrayEquals(ss("John", "Christoph", "Doe"), StringUtils.split("John Christoph Doe", ' ')); assertArrayEquals(ss("John", "", "", "Doe"), StringUtils.split("John,,,Doe", ',')); assertArrayEquals(ss("John", "Doe", ""), StringUtils.split("John Doe ", ' ')); assertArrayEquals(ss("John", "", "", ""), StringUtils.split("John,,,", ',')); }
public static String[] split(String string, char delimiter) { int delimeterCount = 0; int start = 0; int end; while ((end = string.indexOf(delimiter, start)) != -1) { delimeterCount++; start = end + 1; } String[] result = new String[delimeterCount + 1]; start = 0; for (int i = 0; i < delimeterCount; i++) { end = string.indexOf(delimiter, start); result[i] = string.substring(start, end); start = end + 1; } result[delimeterCount] = string.substring(start, string.length()); return result; }
StringUtils { public static String[] split(String string, char delimiter) { int delimeterCount = 0; int start = 0; int end; while ((end = string.indexOf(delimiter, start)) != -1) { delimeterCount++; start = end + 1; } String[] result = new String[delimeterCount + 1]; start = 0; for (int i = 0; i < delimeterCount; i++) { end = string.indexOf(delimiter, start); result[i] = string.substring(start, end); start = end + 1; } result[delimeterCount] = string.substring(start, string.length()); return result; } }
StringUtils { public static String[] split(String string, char delimiter) { int delimeterCount = 0; int start = 0; int end; while ((end = string.indexOf(delimiter, start)) != -1) { delimeterCount++; start = end + 1; } String[] result = new String[delimeterCount + 1]; start = 0; for (int i = 0; i < delimeterCount; i++) { end = string.indexOf(delimiter, start); result[i] = string.substring(start, end); start = end + 1; } result[delimeterCount] = string.substring(start, string.length()); return result; }  }
StringUtils { public static String[] split(String string, char delimiter) { int delimeterCount = 0; int start = 0; int end; while ((end = string.indexOf(delimiter, start)) != -1) { delimeterCount++; start = end + 1; } String[] result = new String[delimeterCount + 1]; start = 0; for (int i = 0; i < delimeterCount; i++) { end = string.indexOf(delimiter, start); result[i] = string.substring(start, end); start = end + 1; } result[delimeterCount] = string.substring(start, string.length()); return result; }  static String[] split(String string, char delimiter); static String encodeUrl(String stringToEncode); static String encodeUrlIso(String stringToEncode); static String decodeUrl(String stringToDecode); static String decodeUrlIso(String stringToDecode); static String md5(String stringToEncode); static String sha1(String stringToEncode); static String digest(String string, String digestAlgo, String encoding); static String hex(byte[] bytes); static byte[] parseHex(String hex); static int parseHexDigit(char c); static String resolveEntity(String entity); static String ellipsize(String text, int maxLength); static String ellipsize(String text, int maxLength, String end); static String[] splitLines(String text, boolean skipEmptyLines); static List<String> findLinesContaining(String text, String searchText); static String join(Iterable<?> iterable, String separator); static String join(int[] array, String separator); static String join(String[] array, String separator); }
StringUtils { public static String[] split(String string, char delimiter) { int delimeterCount = 0; int start = 0; int end; while ((end = string.indexOf(delimiter, start)) != -1) { delimeterCount++; start = end + 1; } String[] result = new String[delimeterCount + 1]; start = 0; for (int i = 0; i < delimeterCount; i++) { end = string.indexOf(delimiter, start); result[i] = string.substring(start, end); start = end + 1; } result[delimeterCount] = string.substring(start, string.length()); return result; }  static String[] split(String string, char delimiter); static String encodeUrl(String stringToEncode); static String encodeUrlIso(String stringToEncode); static String decodeUrl(String stringToDecode); static String decodeUrlIso(String stringToDecode); static String md5(String stringToEncode); static String sha1(String stringToEncode); static String digest(String string, String digestAlgo, String encoding); static String hex(byte[] bytes); static byte[] parseHex(String hex); static int parseHexDigit(char c); static String resolveEntity(String entity); static String ellipsize(String text, int maxLength); static String ellipsize(String text, int maxLength, String end); static String[] splitLines(String text, boolean skipEmptyLines); static List<String> findLinesContaining(String text, String searchText); static String join(Iterable<?> iterable, String separator); static String join(int[] array, String separator); static String join(String[] array, String separator);  }