Here you can find the source of asReader(InputStream input, Charset charset)
Parameter | Description |
---|---|
input | The stream of bytes to read. |
charset | Specify how to decode the bytes. |
public static Reader asReader(InputStream input, Charset charset)
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.nio.charset.Charset; public class Main { /** UTF-8 charset */ public final static Charset UTF8 = Charset.forName("UTF-8"); /**/*from w w w. ja v a2 s. c o m*/ * Convenient method to read a byte stream as a character stream. * * @param input * The stream of bytes to read. * * @return A character stream of bytes decoded in UTF-8. */ public static Reader asReader(InputStream input) { return asReader(input, UTF8); } /** * Convenient method to read a byte stream as a character stream. * * @param input * The stream of bytes to read. * @param charset * Specify how to decode the bytes. * * @return A character stream of bytes properly decoded. */ public static Reader asReader(InputStream input, Charset charset) { return new InputStreamReader(input, charset); } }