Java Encode encodedInputStreamReader(InputStream stream, String encoding)

Here you can find the source of encodedInputStreamReader(InputStream stream, String encoding)

Description

Create a Reader with an explicit encoding around an InputStream.

License

Open Source License

Parameter

Parameter Description
stream An InputStream
encoding A charset encoding

Exception

Parameter Description
IOException If any IO problem

Return

A Reader

Declaration

public static Reader encodedInputStreamReader(InputStream stream,
        String encoding) throws IOException 

Method Source Code

//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);
        }
    }
}

Related

  1. encodeArray(String[] sourceArray, String sysCharset, String charset)
  2. encodeAsModifiedUTF8(String str)
  3. encodeAttribute(String value)
  4. encodeBackslashAhead(char c, char next, Appendable buffer)
  5. encodeCodePoolData(InputStream input)
  6. encodedStringToProperties(String theEncodedPropertyString)
  7. encodeEmail(String s)
  8. encodeFile(String filePath)
  9. encodeForFilter(final String filterString)