- Method in class javax.swing.text.AbstractDocument public void getText (int offset, int length, Segment  txt) throws BadLocationException Gets some text from the document potentially without making a copy. The character array returned in the given Segment should never be mutated. This kind of access to the characters of the document is provided to help make the rendering potentially more efficient. The caller should make no assumptions about the lifetime of the returned character array, which should be copied if needed beyond the use for rendering.Specified by: getText in interface DocumentParameters: offset - the starting offset >= 0 - the number of characters to retrieve >= 0length - the number of characters to retrieve >= 0 - the Segment object to retrieve the text intotxt - the Segment object to retrieve the text intoThrows:BadLocationException - the range given includes a position that is not a valid position within the document