s-day09-文件的换行
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
package com.inmind.io_out01;
|
||||||
|
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/* 文件的换行:
|
||||||
|
Windows:\r\n
|
||||||
|
linux:\n
|
||||||
|
mac:\r
|
||||||
|
|
||||||
|
注意:在同一次流操作中,不停地调用write方法,后面的数据是不会覆盖前面的数据的,之前是new了新流才会覆盖
|
||||||
|
*/
|
||||||
|
public class Demo05 {
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
//字节输出流
|
||||||
|
FileOutputStream fos = new FileOutputStream("a.txt");
|
||||||
|
// fos.write("我是谁\r\n我在哪\r\n我在干嘛".getBytes());
|
||||||
|
fos.write(("我是谁"+System.lineSeparator()+"我在哪"+System.lineSeparator()+"我在干嘛!!!").getBytes());
|
||||||
|
fos.write(("我是谁"+System.lineSeparator()+"我在哪"+System.lineSeparator()+"我在干嘛!!!").getBytes());
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user