From the method getNextParagraph(String text, Point pos) :
int end = text.indexOf('\n', start);
if (end == -1) {
end = text.length();
}
pos.y = end;
// check for "\r\n" sequence
if (text.charAt(end - 1) == '\r') {
return text.substring(start, end - 1);
}
else {
return text.substring(start, end);
}
If text begins with a "\n" character, end is set to 0.
The method call 'text.charAt(end - 1)' will then throw
a StringIndexOutOfBoundsException.
Quick Fix:
if (end != 0 && text.charAt(end - 1) == '\r') {
return text.substring(start, end - 1);
}