public static String newString(int[] codePoints,int offset,int count){
  if (count < 0) {
    throw new IllegalArgumentException();
  }
  char[] chars=new char[count];
  int w=0;
  for (int r=offset, e=offset + count; r < e; ++r) {
    int cp=codePoints[r];
    if (cp < 0 || cp > 0x10ffff) {
      throw new IllegalArgumentException();
    }
    while (true) {
      try {
        if (cp < 0x010000) {
          chars[w]=(char)cp;
          w++;
        }
 else {
          chars[w]=(char)(LEAD_SURROGATE_OFFSET_ + (cp >> LEAD_SURROGATE_SHIFT_));
          chars[w + 1]=(char)(TRAIL_SURROGATE_MIN_VALUE + (cp & TRAIL_SURROGATE_MASK_));
          w+=2;
        }
        break;
      }
 catch (      IndexOutOfBoundsException ex) {
        int newlen=(int)(Math.ceil((double)codePoints.length * (w + 2) / (r - offset + 1)));
        char[] temp=new char[newlen];
        System.arraycopy(chars,0,temp,0,w);
        chars=temp;
      }
    }
  }
  return new String(chars,0,w);
}

public static String newString ( int [ ] codePoints , int offset , int count ) { if ( count < 0 ) { throw new IllegalArgumentException ( ) ; } char [ ] chars = new char [ count ] ; int w = 0 ; for ( int r = offset , e = offset + count ; r < e ; ++ r ) { int cp = codePoints [ r ] ; if ( cp < 0 || cp > 0x10ffff ) { throw new IllegalArgumentException ( ) ; } while ( true ) { try { if ( cp < 0x010000 ) { chars [ w ] = ( char ) cp ; w ++ ; } else { chars [ w ] = ( char ) ( LEAD_SURROGATE_OFFSET_ + ( cp > > LEAD_SURROGATE_SHIFT_ ) ) ; chars [ w + 1 ] = ( char ) ( TRAIL_SURROGATE_MIN_VALUE + ( cp & TRAIL_SURROGATE_MASK_ ) ) ; w += 2 ; } break ; } catch ( IndexOutOfBoundsException ex ) { int newlen = ( int ) ( Math . ceil ( ( double ) codePoints . length * ( w + 2 ) / ( r - offset + 1 ) ) ) ; char [ ] temp = new char [ newlen ] ; System . arraycopy ( chars , 0 , temp , 0 , w ) ; chars = temp ; } } } return new String ( chars , 0 , w ) ; }
cover jdk 1 . 5 api . create a string from an array of codepoints .
