我似乎无法得到任何转义字符为换行符工作? [英] I cannot seem to get any escape characters to work for newlines?
本文介绍了我似乎无法得到任何转义字符为换行符工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道为什么转义字符不会创造新的生产线?
I'm not sure why the escape characters won't create new lines?
MSWord ITSM = new MSWord("C:/users/o519731/Desktop/ITSM.docx");
XWPFParagraph copyITSM = ITSM.Document.createParagraph();
XWPFRun enterText = copyITSM.createRun();
enterText.setText("First line.\n");
enterText.setText("Second line.\n");
enterText.setText("Third line.");
ITSM.Document.write(ITSM.wordStream);
ITSM.wordStream.close();
System.out.println("Document Created.");
结果:
首先Line.Second line.Third线。
在单独的行期望每个:
第一道防线。
第二行。
第三行。
推荐答案
使用的换行符您系统上定义新行转义字符(S)。
如果你希望他们在文件中通过在他们前面添加\\也出现逃避双引号。
Use your systems defined newline escape character(s) for newlines. Also escape double quotes if you wish them to appear in the file by adding a \ in front of them.
String newLine = System.getProperty("line.separator");
enterText.setText("\"First line.\"");
enterText.addBreak();
enterText.setText("\"Second line.\"");
enterText.addBreak();
enterText.setText("\"Third line.\"");
enterText.addBreak();
这篇关于我似乎无法得到任何转义字符为换行符工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文