question: public static String [ ] parseDelimitedList ( String list , char delimiter ) { String delim = "" + delimiter ; StringTokenizer st = new StringTokenizer ( list + delim + " " , delim , true ) ; ArrayList < String > v = new ArrayList < String > ( ) ; String lastToken = "" ; String word = "" ; while ( st . hasMoreTokens ( ) ) { String tok = st . nextToken ( ) ; if ( lastToken != null ) { if ( tok . equals ( delim ) ) { word = word + lastToken ; if ( lastToken . equals ( delim ) ) tok = null ; } else { if ( ! word . equals ( "" ) ) v . add ( word ) ; word = "" ; } } lastToken = tok ; } return v . toArray ( new String [ 0 ] ) ; }
target:  Parse a list of substrings separated by a given delimiter. The delimiter can also appear in substrings (just double them): parseDelimitedString("this|is", '|') returns ["this","is"] parseDelimitedString("this||is", '|') returns ["this|is"]