Java NewLine“\\\<br/>”不保存到文本文件中 [英] Java NewLine &quot;\n&quot; not working in save to text file

查看:301
本文介绍了Java NewLine“\\\<br/>”不保存到文本文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

  public String display(){
return\\\
... ................... \\\
Fixed Employee:\\\
+
Name:+ super.fullName()+
\\ \\ nSalary:+ salary()+
tk\\\
......................;

但是当我从主类调用这个方法时,\\\
newLine不工作。只显示一行输出。请问您能帮忙解决这个问题吗?



谢谢 解决方案

为了保存文件,使用 \r\\\
\\\
因为新行在printstream上可行,但不能写入文件。


Here is my code:

public String display() {
    return "\n......................\nFixed Employee:\n" + 
           "Name: " + super.fullName() + 
           "\nSalary: " + salary() + 
           " tk\n......................";
}

But when I'm invoking this method from main class, "\n" newLine not working. just showing one line output. Will you plz help to solve the problem?

Thanks

解决方案

For saving in files use \r\n. \n as new lines is viable on printstreams but not writing to files.

这篇关于Java NewLine“\\\<br/>”不保存到文本文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆