Java:追加文件内容

文章来源:https://www.cnblogs.com/hello-tl/p/9139367.html

import java.io.*;

public class FileBasicOperation {
  /**
     * 文件追加内容
     * @param file 文件地址
     * @param conent 内容
     */
    public static void fileAdditionalContent(String file, String conent) {
        BufferedWriter out = null;
        try {
            out = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(file, true)));
            out.write(conent);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

文章来源:https://www.cnblogs.com/hello-tl/p/9139367.html

posted @ 2018-06-05 13:43  小田吃饺子  阅读(222)  评论(0编辑  收藏  举报