Java Text File Write by Charset writeFile(String content, File file, Charset encoding)

Here you can find the source of writeFile(String content, File file, Charset encoding)

Description

write File

License

Open Source License

Declaration

public static void writeFile(String content, File file, Charset encoding)
            throws IOException 

Method Source Code

//package com.java2s;
/*/*  w  w  w . ja  va  2 s  .  c  o m*/
 * This software is Copyright by the Board of Trustees of Michigan
 *  State University (c) Copyright 2013, 2014.
 *
 *  You may use this software under the terms of the GNU public license
 *  (GPL). The terms of this license are described at:
 *    http://www.gnu.org/licenses/gpl.txt
 *
 *  Contact Information:
 *       Facility for Rare Isotope Beam
 *       Michigan State University
 *       East Lansing, MI 48824-1321
 *        http://frib.msu.edu
 */

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.Charset;

public class Main {
    public static void writeFile(String content, File file, Charset encoding)
            throws IOException {
        try (Writer out = new BufferedWriter(new OutputStreamWriter(
                new FileOutputStream(file), encoding))) {
            out.write(content);
        }
    }
}

Related

  1. write(String toWrite, File file, Charset charset)
  2. writeAll(Path path, String data, Charset cs)
  3. writeAll(String data, OutputStream outputStream, Charset charset)
  4. writeContent(String content, String charset, File file)
  5. writeFile(File file, String content, Charset charset)
  6. writeFile(String path, String content, Charset charset)
  7. writeFile(String path, String content, Charset encoding)
  8. writeFile(String path, String output, Charset encoding)
  9. writer(OutputStream out, String charset)