Code:
public String getLineText(int lineNumber)
{
try
{
int startIndex = jTextArea1.getLineStartOffset(lineNumber);
int endIndex = jTextArea1.getLineEndOffset(lineNumber);
java.lang.String line = jTextArea1.getText().substring(startIndex, endIndex - startIndex);
return line;
}
catch (BadLocationException ex)
{
return "";
}
}
Note that the "BadLocationException" is thrown if the line number specified didn't exist