FileOutputStream write data additional writing implement and linefeed

Wrap:
Here Insert Picture Description

//创建字节输出流对象
		//加参数true,就是追加写,不加就是重新写
		FileOutputStream f=new FileOutputStream("2.txt",true);
		
		for(int x=0;x<10;x++){
			f.write(("hello"+x).getBytes());
			f.write("\r\n".getBytes());//换行
		}
		
		//关闭流
		f.close();

result:

hello0
hello1
hello2
hello3
hello4
hello5
hello6
hello7
hello8
hello9
hello0
hello1
hello2
hello3
hello4
hello5
hello6
hello7
hello8
hello9
hello0
hello1
hello2
hello3
hello4
hello5
hello6
hello7
hello8
hello9
He published 188 original articles · won praise 10 · views 10000 +

Guess you like

Origin blog.csdn.net/Ting1king/article/details/105007552