Java BufferedWriter Create getBufferedWriter(String file, String fileCharset)

Here you can find the source of getBufferedWriter(String file, String fileCharset)

Description

Get the buffered writer

License

Open Source License

Parameter

Parameter Description
file String
fileCharset String

Exception

Parameter Description
UnsupportedEncodingException The exception
FileNotFoundException The exception

Return

BufferedWriter

Declaration

private static BufferedWriter getBufferedWriter(String file, String fileCharset)
        throws UnsupportedEncodingException, FileNotFoundException 

Method Source Code


//package com.java2s;

import java.io.BufferedWriter;

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

import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;

public class Main {
    /**/*from  w  w w.jav a  2  s . co  m*/
     * Get the buffered writer
     *
     * @param file String
     * @param fileCharset String
     * @return BufferedWriter
     * @throws UnsupportedEncodingException The exception
     * @throws FileNotFoundException The exception
     */
    private static BufferedWriter getBufferedWriter(String file, String fileCharset)
            throws UnsupportedEncodingException, FileNotFoundException { // FIXME move this logic to core module
        BufferedWriter fs = null;
        if (fileCharset != null && fileCharset.trim().length() > 0) {
            fs = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), fileCharset.trim()));
        } else {
            fs = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
        }
        return fs;
    }
}

Related

  1. getBufferedWriter(File file)
  2. getBufferedWriter(final Writer out)
  3. getBufferedWriter(OutputStream os)
  4. getBufferedWriter(String directory, String filename)
  5. getBufferedWriter(String file)
  6. getBufferedWriter(String filePath, String encoding)
  7. getBufferedWriter(String path)
  8. getBufferedWriter(String path, String charset, boolean isAppend)
  9. getBufferedWriterOnFile(File file, String format)