【FileOutputStream类:文档中的换行与追加】

package test;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author shusheng
 * @description 文档中的换行与追加
 * @Email shusheng@yiji.com
 * @date 2018/11/9 14:50
 */
public class FileOutputStreamDemo3 {

    public static void main(String[] args) throws IOException {
        /**
         *换行:
         *不同的操作系统的换行符不同:Windows的为
, linux:
, Mac:
         *追加:
         *把FileOutputStream("fos.txt")改为FileOutputStream("fos.txt",true)
         */
        FileOutputStream fos = new FileOutputStream("fos.txt",true);
        for(int x=0; x<10; x++){
            fos.write(("hello"+x).getBytes());
            fos.write(("
").getBytes());
        }
        fos.close();
    }

}
终身学习者
原文地址:https://www.cnblogs.com/zuixinxian/p/9936011.html