站长资讯网
最全最丰富的资讯网站

java中怎么换行

java中怎么换行

java中实现换行有以下几种方法:

1.使用java中的转义符"rn": (推荐学习:java课程)

String str="aaa"; str+="rn";

这样在str后面就有换行了.

注意:r,n的顺序是不能够对换的,否则不能实现换行的效果。

2.BufferedWriter的newline()方法:

FileOutputStream fos=new FileOutputStream("c;\11.txt"); BufferedWriter bw=new BufferedWriter(fos); bw.write("你好"); bw.newline(); bw.write("java"); w.newline();

3.使用System.getProperty()方法:

String str = "aaa"+System.getProperty("line.separator");

赞(0)
分享到: 更多 (0)

网站地图   沪ICP备18035694号-2    沪公网安备31011702889846号