Here you can find the source of getReader(final InputStream is, final String enc)
public static Reader getReader(final InputStream is, final String enc) throws UnsupportedEncodingException
//package com.java2s; /*/*w w w . j a va2 s . c om*/ * Copyright 2006-2012 The Scriptella Project Team. * * 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.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.UnsupportedEncodingException; public class Main { /** * @return buffered reader for specified input stream. * @see #getReader(java.io.InputStream, String, boolean) */ public static Reader getReader(final InputStream is, final String enc) throws UnsupportedEncodingException { return getReader(is, enc, true); } /** * Returns reader for specified input stream and charset name. * * @param is source input stream. * @param enc charset name, null means default. * @param buffered true if buffered reader should be used. * @return reader for inputstream. * @throws UnsupportedEncodingException If the named charset is not supported */ public static Reader getReader(final InputStream is, final String enc, final boolean buffered) throws UnsupportedEncodingException { Reader r = enc == null ? new InputStreamReader(is) : new InputStreamReader(is, enc); return buffered ? new BufferedReader(r) : r; } }