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

猜你喜欢

转载自www.cnblogs.com/hello-tl/p/9139367.html