Reading JTextPane line by line
3 answers
Element root = textPane.getDocument().getDefaultRootElement();
Once you get the root element, you can check how many children (i.e. rows) there are. Then you can get each child and use the start / end offset methods to get the text for that particular line.
This will be more efficient than getting all the text on one big line and then splitting it up.
+2
source to share