转移字符是针对html的,所以,你放在文本里,就是这样了

解决方案 »

  1.   

    String filehead12=abcdefg
    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();
      

  2.   

    我知道了,应该用:
    out12.write("<HASH_SIGN>0"+"\n");
      

  3.   

    wjmmml(笑着悲伤)
    试过了,不行的。
    跟AscII码,uicode有关吧
    请教!
      

  4.   

    在是是这个:
    out12.write("<HASH_SIGN>0"+"\\n");
      

  5.   

    我认为是和本文编辑软件有关。
    你用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').
      

  6.   

    wjmmml(笑着悲伤):你说的不行
    黑块倒是没了,换行还没实现,成了/n
      

  7.   

    xiao_yuer(小鱼儿) 说得比较对,用ue编辑的
    用ue打开没事
    用笔记本打开就不行
    不知是何道理
      

  8.   

    这么说吧,因为notepad只是在windows平台下使用的,你用"\r\n"输出的换行符他才可以正确识别,不会显示黑块。
    而UltraEdit或其他的文本编辑器可以自动识别各种平台下的换行符。
    所以你要为了让notepad(记事本)也能正确显示的话,你得如下改:
    out12.write("<element>\r\n");
    最好是用pw.println("<element>");