Java Text File Write by Charset writerBuffered(final File file, final Charset charset)

Here you can find the source of writerBuffered(final File file, final Charset charset)

Description

Open a buffered Writer , equivalent to:
new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset));

License

Open Source License

Parameter

Parameter Description
file the file to open
charset the charset to decode the file contents

Exception

Parameter Description
FileNotFoundException if the file could not be opened

Return

the buffered reader from the file

Declaration

public static final BufferedWriter writerBuffered(final File file, final Charset charset)
        throws FileNotFoundException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedWriter;
import java.io.File;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import java.io.OutputStreamWriter;

import java.nio.charset.Charset;

public class Main {
    /** Open a buffered {@link Writer}, equivalent to:<br/>
     * {@code new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset));}
     * @param file the file to open/*from   w w w .  j a  v  a  2  s. co m*/
     * @param charset the charset to decode the file contents
     * @return the buffered reader from the file
     * @throws FileNotFoundException if the file could not be opened
     */
    public static final BufferedWriter writerBuffered(final File file, final Charset charset)
            throws FileNotFoundException {
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset));
        return writer;
    }
}

Related

  1. writeFile(String path, String content, Charset charset)
  2. writeFile(String path, String content, Charset encoding)
  3. writeFile(String path, String output, Charset encoding)
  4. writer(OutputStream out, String charset)
  5. writer(String path, String content, String charset)
  6. writeStreamToString(InputStream is, String charsetName)
  7. writeString(OutputStream os, String string, CharsetEncoder encoder)
  8. writeString(OutputStream out, String charset, String value)
  9. writeStringToFile(File file, String s, String charset)