| 473 | } |
| 474 | |
| 475 | public void getChars(int srcOffset, int srcEnd, |
| 476 | char[] dst, int dstOffset) |
| 477 | { |
| 478 | if (srcOffset < 0) |
| 479 | throw new StringIndexOutOfBoundsException(srcOffset); |
| 480 | else if (srcEnd > length) |
| 481 | throw new StringIndexOutOfBoundsException(srcEnd); |
| 482 | |
| 483 | int srcLength = srcEnd-srcOffset; |
| 484 | if (data instanceof char[]) { |
| 485 | char[] src = (char[]) data; |
| 486 | System.arraycopy(src, offset + srcOffset, dst, dstOffset, srcLength); |
| 487 | } else { |
| 488 | byte[] src = (byte[]) data; |
| 489 | for (int i = 0; i < srcLength; ++i) { |
| 490 | dst[i + dstOffset] = (char) src[i + offset + srcOffset]; |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | public char[] toCharArray() { |
| 496 | char[] b = new char[length]; |