Here you can find the source of writer(OutputStream out, String charset)
static public OutputStreamWriter writer(OutputStream out, String charset)
//package com.java2s; /******************************************************************************* * Copyright 2012 Urbancode, Inc/* www . jav a2s. com*/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; import java.nio.charset.CharsetEncoder; public class Main { static public OutputStreamWriter writer(OutputStream out, String charset) { OutputStreamWriter result; if (charset == null) { result = writer(out); } else { result = writer(out, Charset.forName(charset)); } return result; } static public OutputStreamWriter writer(OutputStream out, CharsetEncoder encoder) { OutputStreamWriter result; if (encoder == null) { result = writer(out); } else { result = new OutputStreamWriter(out, encoder); } return result; } static public OutputStreamWriter writer(OutputStream out, Charset charset) { OutputStreamWriter result; if (charset == null) { result = writer(out); } else { CharsetEncoder encoder; encoder = charset.newEncoder(); result = writer(out, encoder); } return result; } static public OutputStreamWriter writer(OutputStream out) { OutputStreamWriter result; result = new OutputStreamWriter(out); return result; } }