Java Text File Write writeString(String filePath, boolean append, String content, String encoding)

Here you can find the source of writeString(String filePath, boolean append, String content, String encoding)

Description

write String

License

Apache License

Declaration

public static void writeString(String filePath, boolean append, String content, String encoding)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {

    public static void writeString(String filePath, boolean append, String content) throws IOException {
        writeString(filePath, append, content, "UTF-8");
    }//from   ww  w  . j  ava2s  . c  om

    public static void writeString(String filePath, boolean append, String content, String encoding)
            throws IOException {
        writeBytes(filePath, append, content.getBytes(encoding));
    }

    public static void writeBytes(String filePath, boolean append, byte[] content) throws IOException {
        FileOutputStream fos = new FileOutputStream(filePath, append);
        try {
            fos.write(content);
            fos.flush();
        } finally {
            fos.close();
        }

    }
}

Related

  1. writeString(String contents, File file)
  2. writeString(String contents, File file)
  3. writeString(String data, File file)
  4. writeString(String data, String file_path)
  5. writeString(String fileName, String str)
  6. writeString(String filePath, String content)
  7. writeString(String par0)
  8. writeString(String path, String key, String value)
  9. writeString(String path, String str)