我有一个 TextArea 和其中的几行文本。当我通过 getText() 方法提取字符串时,我得到的是一行文本,而不是真正写的几行。那么如何区分 TextArea 中的每一行呢?
请您参考如下方法:
像这样使用.replaceAll,
//replace the line breaks "\n" with System line separator...
//replace "yourTextAreaVariabe" with your own...
yourTextAreaVariable.getText().replaceAll("\n", System.getProperty("line.separator"));