Java PrintWriter Create getPrintWriter(String path, String charset, boolean isAppend)

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

Description

get Print Writer

License

Apache License

Declaration

public static PrintWriter getPrintWriter(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 PrintWriter getPrintWriter(String path, String charset, boolean isAppend) throws IOException {
        return new PrintWriter(getBufferedWriter(path, charset, isAppend));
    }/*from  ww  w. j  av a2 s  .co m*/

    public static BufferedWriter getBufferedWriter(String path, String charset, boolean isAppend)
            throws IOException {
        return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(touch(path), isAppend), charset));
    }

    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. getPrintwriter(File file, boolean append)
  2. getPrintWriter(final File aFile, final boolean append)
  3. getPrintWriter(String filename)
  4. getPrintWriter(String fileName, Writer out)
  5. getPrintWriter(String nombreFichero)