我有一个 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")); 


评论关闭
IT源码网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!