@Test public void testGetTokens() { final String input = "string with; tokens ; delimited by ; ; semicolons; there;; are 7 tokens."; final List<String> tokens = StringUtil.getTokens(input,";"); assertEquals(7, tokens.size()); assertEquals("string with", tokens.get(0)); assertEquals(" tokens ", tokens.get(1)); assertEquals(" delimited by ", tokens.get(2)); assertEquals(" ", tokens.get(3)); assertEquals(" semicolons", tokens.get(4)); assertEquals(" there", tokens.get(5)); assertEquals(" are 7 tokens.", tokens.get(6)); }
public static List<String> getTokens(String str, String delimiter) { ArrayList<String> l = new ArrayList<String>(); StringTokenizer tokens = new StringTokenizer(str, delimiter); while(tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; }
StringUtil { public static List<String> getTokens(String str, String delimiter) { ArrayList<String> l = new ArrayList<String>(); StringTokenizer tokens = new StringTokenizer(str, delimiter); while(tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; } }
StringUtil { public static List<String> getTokens(String str, String delimiter) { ArrayList<String> l = new ArrayList<String>(); StringTokenizer tokens = new StringTokenizer(str, delimiter); while(tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; } private  StringUtil(); }
StringUtil { public static List<String> getTokens(String str, String delimiter) { ArrayList<String> l = new ArrayList<String>(); StringTokenizer tokens = new StringTokenizer(str, delimiter); while(tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; } private  StringUtil(); static String join(Collection<String> strings, String delimiter); static String toString( final Object[] array, final String delim ); static String toString( final Object[] array, final String delim, boolean includeBrackets); static String toString( final Object[] array ); static List<String> split(String str, String splitter); static String replace(String source, String search, String replace); static String replaceAll(String source, String search, String replace); static List<String> getTokens(String str, String delimiter); static String getLastToken(String str, String delimiter); static String getFirstToken(String str, String delimiter); static String getStackTrace( final Throwable t ); static boolean isEmpty(final String text); static int indexOfIgnoreCase(final String text, final String str); static boolean startsWithIgnoreCase(final String text, final String prefix); static boolean endsWithIgnoreCase(final String text, final String suffix); static boolean isLetter(char c); static boolean isDigit(char c); static boolean isLetterOrDigit(char c); @SuppressWarnings("unchecked") static T valueOf(String value, Class type); static boolean equalsIgnoreCase(String s1, String s2); static T caseInsensitiveValueOf(Class<T> enumType, String name); static List<String> tokenize(String str, char delim); static String unescape(CharSequence string, int quoteChar, boolean useAsciiEscapes, StringBuilder sb); }
StringUtil { public static List<String> getTokens(String str, String delimiter) { ArrayList<String> l = new ArrayList<String>(); StringTokenizer tokens = new StringTokenizer(str, delimiter); while(tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; } private  StringUtil(); static String join(Collection<String> strings, String delimiter); static String toString( final Object[] array, final String delim ); static String toString( final Object[] array, final String delim, boolean includeBrackets); static String toString( final Object[] array ); static List<String> split(String str, String splitter); static String replace(String source, String search, String replace); static String replaceAll(String source, String search, String replace); static List<String> getTokens(String str, String delimiter); static String getLastToken(String str, String delimiter); static String getFirstToken(String str, String delimiter); static String getStackTrace( final Throwable t ); static boolean isEmpty(final String text); static int indexOfIgnoreCase(final String text, final String str); static boolean startsWithIgnoreCase(final String text, final String prefix); static boolean endsWithIgnoreCase(final String text, final String suffix); static boolean isLetter(char c); static boolean isDigit(char c); static boolean isLetterOrDigit(char c); @SuppressWarnings("unchecked") static T valueOf(String value, Class type); static boolean equalsIgnoreCase(String s1, String s2); static T caseInsensitiveValueOf(Class<T> enumType, String name); static List<String> tokenize(String str, char delim); static String unescape(CharSequence string, int quoteChar, boolean useAsciiEscapes, StringBuilder sb);  }