catch (StringIndexOutOfBoundsException ex) { int invalid = 0; if (seg.offset < 0 || seg.offset >= seg.array.length) invalid = seg.offset; else invalid = seg.offset + seg.count; throw new BadLocationException("Illegal location: array.length = " + seg.array.length + ", offset = " + seg.offset + ", count = " + seg.count, invalid); } }
    public String getString(int where, int len) throws BadLocationException    {    Segment seg = new Segment();    getChars(where, len, seg);    return new String(seg.array, seg.offset, seg.count);    }