Here you can find the source of getCharAt(Document document, int position)
public static char getCharAt(Document document, int position) throws BadLocationException
//package com.java2s; import javax.swing.text.BadLocationException; import javax.swing.text.Document; public class Main { public static char getCharAt(Document document, int position) throws BadLocationException { return document.getText(position, 1).charAt(0); }/* ww w. ja v a 2 s .co m*/ public static String getText(Document document) { try { return document.getText(0, document.getLength()); } catch (Throwable t) { t.printStackTrace(); return ""; } } }