private String characterIteratorToString(CharacterIterator iterator){
  int endIndex=iterator.getEndIndex();
  int beginIndex=iterator.getBeginIndex();
  int count=endIndex - beginIndex;
  if (count <= 0) {
    return "";
  }
  char[] chars=new char[count];
  int i=0;
  char c=iterator.first();
  while (c != CharacterIterator.DONE) {
    chars[i]=c;
    i++;
    c=iterator.next();
  }
  return new String(chars);
}

private String characterIteratorToString ( CharacterIterator iterator ) { int endIndex = iterator . getEndIndex ( ) ; int beginIndex = iterator . getBeginIndex ( ) ; int count = endIndex - beginIndex ; if ( count <= 0 ) { return "" ; } char [ ] chars = new char [ count ] ; int i = 0 ; char c = iterator . first ( ) ; while ( c != CharacterIterator . DONE ) { chars [ i ] = c ; i ++ ; c = iterator . next ( ) ; } return new String ( chars ) ; }
returns a string containing the characters from the given iterator .
