Java BufferedWriter Create getBufferedWriter(String path, String charset, boolean isAppend)

Here you can find the source of getBufferedWriter(String path, String charset, boolean isAppend)

Description

get Buffered Writer

License

Apache License

Declaration

public static BufferedWriter getBufferedWriter(String path, String charset, boolean isAppend)
        throws IOException 

Method Source Code


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

import java.io.*;

public class Main {

    public static BufferedWriter getBufferedWriter(String path, String charset, boolean isAppend)
            throws IOException {
        return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(touch(path), isAppend), charset));
    }//from w  w  w .j  a v  a2  s .  co  m

    public static File touch(String fullFilePath) throws IOException {
        if (fullFilePath == null) {
            return null;
        }
        File file = new File(fullFilePath);

        file.getParentFile().mkdirs();
        if (!file.exists())
            file.createNewFile();
        return file;
    }
}

Related

  1. getBufferedWriter(String directory, String filename)
  2. getBufferedWriter(String file)
  3. getBufferedWriter(String file, String fileCharset)
  4. getBufferedWriter(String filePath, String encoding)
  5. getBufferedWriter(String path)
  6. getBufferedWriterOnFile(File file, String format)
  7. toBufferedWriter(Writer w)