Here you can find the source of encodedInputStreamReader(InputStream stream, String encoding)
Parameter | Description |
---|---|
stream | An InputStream |
encoding | A charset encoding |
Parameter | Description |
---|---|
IOException | If any IO problem |
public static Reader encodedInputStreamReader(InputStream stream, String encoding) throws IOException
//package com.java2s; import java.io.*; public class Main { /** Create a Reader with an explicit encoding around an InputStream. * This static method will treat null as meaning to use the platform default, * unlike the Java library methods that disallow a null encoding. */*from w w w . j av a 2 s . co m*/ * @param stream An InputStream * @param encoding A charset encoding * @return A Reader * @throws IOException If any IO problem */ public static Reader encodedInputStreamReader(InputStream stream, String encoding) throws IOException { // InputStreamReader doesn't allow encoding to be null; if (encoding == null) { return new InputStreamReader(stream); } else { return new InputStreamReader(stream, encoding); } } }