public class UnicodeReader extends Reader
Generic unicode textReader, which will use BOM mark to identify the encoding to be used. If BOM is not found then use a given default or system encoding.
Usage pattern: String enc = "ISO-8859-1"; // or NULL to use systemDefault FileInputStream fis = new FileInputStream(file); UnicodeReader uReader = new UnicodeReader(fis, enc); enc = uReader.getEncoding(); // check and skip possible BOM bytes or: UnicodeReader uin = new UnicodeReader(fis, enc).skipBOM();| 构造器和说明 |
|---|
UnicodeReader(InputStream in) |
UnicodeReader(InputStream in,
String defaultEnc) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
String |
getDefaultEncoding() |
String |
getEncoding()
Get stream encoding or NULL if stream is uninitialized.
|
protected void |
init()
Read-ahead four bytes and check for BOM marks.
|
int |
read(char[] cBuf,
int off,
int len) |
UnicodeReader |
skipBOM() |
public UnicodeReader(InputStream in)
in - inputStream to be readpublic UnicodeReader(InputStream in, String defaultEnc)
in - inputStream to be readdefaultEnc - default encoding if stream does not have
BOM marker. Give NULL to use system-level default.public UnicodeReader skipBOM()
public String getDefaultEncoding()
public String getEncoding()
protected void init()
throws IOException
IOExceptionpublic void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在类中 ReaderIOExceptionpublic int read(char[] cBuf,
int off,
int len)
throws IOException
read 在类中 ReaderIOExceptionCopyright © 2015. All rights reserved.