• FileOutPutStream


    package ad;

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

    /*
    追加写/续写:使用两个参数的构造方法
    FileOutputStream(String name, boolean append)创建一个向具有指定 name 的文件中写入数据的输出文件流。
    FileOutputStream(File file, boolean append) 创建一个向指定 File 对象表示的文件中写入数据的文件输出流。
    参数:
    String name,File file:写入数据的目的地
    boolean append:追加写开关
    true:创建对象不会覆盖源文件,继续在文件的末尾追加写数据
    false:创建一个新文件,覆盖源文件
    写换行:写换行符号
    windows:
    linux:/n
    mac:/r
    */
    public class Demo03OutputStream {
    public static void main(String[] args) throws IOException {
    FileOutputStream fos = new FileOutputStream("09_IOAndPropertiesc.txt",true);
    for (int i = 1; i <=10 ; i++) {
    fos.write("你好".getBytes());
    fos.write(" ".getBytes());
    }

        fos.close();
    }
    

    }
    package ad;

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

    /*
    追加写/续写:使用两个参数的构造方法
    FileOutputStream(String name, boolean append)创建一个向具有指定 name 的文件中写入数据的输出文件流。
    FileOutputStream(File file, boolean append) 创建一个向指定 File 对象表示的文件中写入数据的文件输出流。
    参数:
    String name,File file:写入数据的目的地
    boolean append:追加写开关
    true:创建对象不会覆盖源文件,继续在文件的末尾追加写数据
    false:创建一个新文件,覆盖源文件
    写换行:写换行符号
    windows:
    linux:/n
    mac:/r
    */
    public class Demo03OutputStream {
    public static void main(String[] args) throws IOException {
    FileOutputStream fos = new FileOutputStream("09_IOAndPropertiesc.txt",true);
    for (int i = 1; i <=10 ; i++) {
    fos.write("你好".getBytes());
    fos.write(" ".getBytes());
    }

        fos.close();
    }
    

    }

  • 相关阅读:
    Codeigniter 控制器的继承问题
    laravel 安装
    js preventDefault() 方法
    jquery 获取$("#id").text()里面的值 需要进行去空格去换行符操作
    HDU_1394_线段树
    Codeforces_723_D
    Codeforces_723_C
    Codeforces_723_B
    Codeforces_723_A
    HDU_4456_二维树状数组
  • 原文地址:https://www.cnblogs.com/hk18181358129/p/13263719.html
Copyright © 2020-2023  润新知