public void getChars(int where, int len, Segment txt) throws BadLocationException { CharBuffer b = buffer; int start = b.getSegment(where, len); if (start < 0) throw new BadLocationException("invalid offset", where); txt.offset = start; txt.array = b.getArray(); txt.count = len; }