Java Text File Write by Charset getWriter(OutputStream out, String charsetName)

Here you can find the source of getWriter(OutputStream out, String charsetName)

Description

get Writer

License

Apache License

Declaration

public static OutputStreamWriter getWriter(OutputStream out, String charsetName) 

Method Source Code

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

import java.io.OutputStream;
import java.io.OutputStreamWriter;

import java.nio.charset.Charset;

public class Main {

    public static OutputStreamWriter getWriter(OutputStream out, String charsetName) {
        return getWriter(out, Charset.forName(charsetName));
    }/*  w  w  w. j  a  va 2s . com*/

    public static OutputStreamWriter getWriter(OutputStream out, Charset charset) {
        if (null == out) {
            return null;
        }

        if (null == charset) {
            return new OutputStreamWriter(out);
        } else {
            return new OutputStreamWriter(out, charset);
        }
    }
}

Related

  1. copy(byte[] input, Writer output, Charset charset)
  2. createWriter(@Nullable final OutputStream aOS, @Nonnull final Charset aCharset)
  3. createWriter(@Nullable final OutputStream aOS, @Nonnull final String sCharset)
  4. getWriter(OutputStream os, String charset)
  5. getWriter(String fileName, Charset cs)
  6. getWriter(String path, Charset encoding)
  7. newFilePrintWriter(File file, Charset charset)
  8. newWriter(File file, Charset charset)