国产成人毛片视频|星空传媒久草视频|欧美激情草久视频|久久久久女女|久操超碰在线播放|亚洲强奸一区二区|五月天丁香社区在线|色婷婷成人丁香网|午夜欧美6666|纯肉无码91视频

java輸入回車則結束輸入 JAVA輸出內(nèi)容打印到TXT以及不同系統(tǒng)中如何換行?

JAVA輸出內(nèi)容打印到TXT以及不同系統(tǒng)中如何換行?java中寫.txt文件,實現(xiàn)換行的幾種方法:1.使用java中的轉(zhuǎn)義符"rn":Java代碼 String str="aaa" str ="

JAVA輸出內(nèi)容打印到TXT以及不同系統(tǒng)中如何換行?

java中寫.txt文件,實現(xiàn)換行的幾種方法:

1.使用java中的轉(zhuǎn)義符"rn":

Java代碼

String str="aaa"

str ="rn"

String str="aaa"

str ="rn"

這樣在str后面就有換行了.

 注意:r,n的順序是不能夠?qū)Q的,否則不能實現(xiàn)換行的效果.

2.BufferedWriter的newline()方法:

Java代碼

FileOutputStream fos=new FileOutputStream("c11.txt")

BufferedWriter bw=new BufferedWriter(fos)

bw.write("你好")

bw.newline()

bw.write("java")

w.newline()

FileOutputStream fos=new FileOutputStream("c11.txt")

BufferedWriter bw=new BufferedWriter(fos)

bw.write("你好")

bw.newline()

bw.write("java")

bw.newline()

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

Java代碼

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

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