user6469344
user6469344

Reputation:

How to get text from TextArea in JavaFX saving line breaks?

I have a TextArea and a few lines of text in it. When I extract String by getText() method what I`m getting is a line of text instead of really written few lines. So what can I do to distinguishevery line in TextArea?

Upvotes: 0

Views: 9117

Answers (1)

Pascal Msoka
Pascal Msoka

Reputation: 56

Use the .replaceAll like this,

//replace the line breaks "\n" with System line separator...
//replace "yourTextAreaVariabe" with your own...
yourTextAreaVariable.getText().replaceAll("\n", System.getProperty("line.separator"));

Upvotes: 0

Related Questions