Java tutorial
import javax.swing.JTextPane; import javax.swing.text.Element; public class Main { public static void main(String[] argv) throws Exception { JTextPane textPane = new JTextPane(); Element section = textPane.getDocument().getDefaultRootElement(); int paraCount = section.getElementCount(); for (int i = 0; i < paraCount; i++) { Element e = section.getElement(i); int rangeStart = e.getStartOffset(); int rangeEnd = e.getEndOffset(); String para = textPane.getText(rangeStart, rangeEnd - rangeStart); System.out.println(para); } } }