我认为是和本文编辑软件有关。 你用UltraEdit打开就不会有这样的现象。 还有我一般输出都是换行符都是在封装一下: PrintWriter pw = new PrintWriter(out12); 然后用pw.println()和print方便了很多。因为不同的系统下,换行符是不一样的,windows下是"\r\n",其他的事'\n',而用PrintWriter.println()它会自动判断的。 JDK API如是说: public void println() Terminate the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').
String filename12=filehead12+".EMS";
BufferedWriter out12 = new BufferedWriter(new FileWriter("e:\\"+filename12));
out12.write(filehead12);
out12.write("<element>\n");
out12.write("<HASH_SIGN>0"+'\n');
out12.write("<ems_edi_org_exg>\n");
out12.write("</element>");
out12.close();
out12.write("<HASH_SIGN>0"+"\n");
试过了,不行的。
跟AscII码,uicode有关吧
请教!
out12.write("<HASH_SIGN>0"+"\\n");
你用UltraEdit打开就不会有这样的现象。
还有我一般输出都是换行符都是在封装一下:
PrintWriter pw = new PrintWriter(out12);
然后用pw.println()和print方便了很多。因为不同的系统下,换行符是不一样的,windows下是"\r\n",其他的事'\n',而用PrintWriter.println()它会自动判断的。
JDK API如是说:
public void println()
Terminate the current line by writing the line separator string. The line separator string is defined by the system property line.separator, and is not necessarily a single newline character ('\n').
黑块倒是没了,换行还没实现,成了/n
用ue打开没事
用笔记本打开就不行
不知是何道理
而UltraEdit或其他的文本编辑器可以自动识别各种平台下的换行符。
所以你要为了让notepad(记事本)也能正确显示的话,你得如下改:
out12.write("<element>\r\n");
最好是用pw.println("<element>");