public static void toString(Iterator<?> iter,String separator,StringBuilder sb){
  while (iter.hasNext()) {
    sb.append(iter.next());
    if (iter.hasNext()) {
      sb.append(separator);
    }
  }
}

public static void toString ( Iterator < ? > iter , String separator , StringBuilder sb ) { while ( iter . hasNext ( ) ) { sb . append ( iter . next ( ) ) ; if ( iter . hasNext ( ) ) { sb . append ( separator ) ; } } }
converts an iterator to a string by concatenating all of the string representations of objects in the iterator , divided by a separator .
