public static Collection<String> string2Collection(String in,String delimiter,boolean doStrip,Collection<String> collection){
  if (in == null) {
    return null;
  }
  if (collection == null) {
    collection=new ArrayList<String>();
  }
  if (delimiter == null || delimiter.length() == 0) {
    collection.add(in);
    return collection;
  }
  int fromIndex=0;
  int pos;
  while ((pos=in.indexOf(delimiter,fromIndex)) >= 0) {
    String interim=in.substring(fromIndex,pos);
    if (doStrip) {
      interim=strip(interim);
    }
    if (!doStrip || interim.length() > 0) {
      collection.add(interim);
    }
    fromIndex=pos + delimiter.length();
  }
  String interim=in.substring(fromIndex);
  if (doStrip) {
    interim=strip(interim);
  }
  if (!doStrip || interim.length() > 0) {
    collection.add(interim);
  }
  return collection;
}

public static Collection < String > string2Collection ( String in , String delimiter , boolean doStrip , Collection < String > collection ) { if ( in == null ) { return null ; } if ( collection == null ) { collection = new ArrayList < String > ( ) ; } if ( delimiter == null || delimiter . length ( ) == 0 ) { collection . add ( in ) ; return collection ; } int fromIndex = 0 ; int pos ; while ( ( pos = in . indexOf ( delimiter , fromIndex ) ) >= 0 ) { String interim = in . substring ( fromIndex , pos ) ; if ( doStrip ) { interim = strip ( interim ) ; } if ( ! doStrip || interim . length ( ) > 0 ) { collection . add ( interim ) ; } fromIndex = pos + delimiter . length ( ) ; } String interim = in . substring ( fromIndex ) ; if ( doStrip ) { interim = strip ( interim ) ; } if ( ! doStrip || interim . length ( ) > 0 ) { collection . add ( interim ) ; } return collection ; }
converts a delimited string to a collection of strings . substrings between delimiters are extracted from the string and added to a collection that is provided by the caller .
