FileOutputStream書き込みデータの追記実装と改行

ラップ:
ここに画像を挿入説明

//创建字节输出流对象
		//加参数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();

結果:

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
彼は188元の記事を発表 ウォン称賛10 ビュー10000 +

おすすめ

転載: blog.csdn.net/Ting1king/article/details/105007552