简体   繁体   中英

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?

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"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM