public class InputStreamReader extends Reader
charset
。字符集,它使用可指定名称或可给予明确,或平台的默认字符集可以接受。
每次调用一个inputstreamreader的read()方法可能会导致一个或多个字节是从底层字节输入流中读取。为了使字节的有效转换为字符,更多的字节可以从底层流读取,而不是满足当前读操作的必要。
为了获得最好的效率,考虑包装inputstreamreader在体。例如:
BufferedReader=是(新inputstreamreader(系统的));
BufferedReader
,
InputStream
,
Charset
Constructor and Description |
---|
InputStreamReader(InputStream in)
创建一个inputstreamreader使用默认字符集。
|
InputStreamReader(InputStream in, Charset cs)
创建一个inputstreamreader使用给定的字符集。
|
InputStreamReader(InputStream in, CharsetDecoder dec)
创建一个inputstreamreader使用给定的字符集解码。
|
InputStreamReader(InputStream in, String charsetName)
创建一个inputstreamreader使用指定的字符集。
|
public InputStreamReader(InputStream in)
in
- An InputStream
public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException
in
- An InputStream
charsetName
-支持的
charset
名称
UnsupportedEncodingException
-如果指定的字符集不支持
public InputStreamReader(InputStream in, Charset cs)
in
- An InputStream
cs
-字符集
public InputStreamReader(InputStream in, CharsetDecoder dec)
in
- An InputStream
dec
-字符集解码
public String getEncoding()
如果编码具有一个历史名称,则返回名称;否则将返回编码的规范名称。
如果这种情况与InputStreamReader(InputStream, String)
然后构造函数返回的名称创建独特的编码,可能与名字传递给构造函数。这个方法将返回null
流已经关闭。
null
如果流已关闭
Charset
public int read() throws IOException
read
方法重写,继承类
Reader
IOException
如果I/O错误发生
public int read(char[] cbuf, int offset, int length) throws IOException
read
方法重写,继承类
Reader
cbuf
-目的缓冲区
offset
偏移,开始存储字符
length
-最大字符数读
IOException
如果I/O错误发生
public boolean ready() throws IOException
ready
方法重写,继承类
Reader
IOException
如果I/O错误发生
public void close() throws IOException
Reader
close
接口
Closeable
close
接口
AutoCloseable
close
方法重写,继承类
Reader
IOException
如果I/O错误发生
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.