Java OutputStreamWriter Create getOutputStreamWriter(OutputStream out)

Here you can find the source of getOutputStreamWriter(OutputStream out)

Description

Returns a writer for the specified output stream, using UTF-8 encoding.

License

Open Source License

Parameter

Parameter Description
out the output stream to wrap

Return

a writer for this output stream

Declaration

public static Writer getOutputStreamWriter(OutputStream out) 

Method Source Code

//package com.java2s;

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

import java.io.UnsupportedEncodingException;
import java.io.Writer;

public class Main {
    /**/*  w ww . j  av  a2s  .c o  m*/
     * Returns a writer for the specified output stream, using UTF-8 encoding.
     * @param out the output stream to wrap
     * @return a writer for this output stream
     */
    public static Writer getOutputStreamWriter(OutputStream out) {
        try {
            return new OutputStreamWriter(out, "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec
        }
    }
}

Related

  1. newOutputStreamWriter(OutputStream os)