public class BOMInputStream extends InputStream
getCharset()方法调用后会得到BOM头的编码,且会去除BOM头
String enc = "UTF-8"; // or NULL to use systemdefault
FileInputStream fis = new FileInputStream(file);
BOMInputStream uin = new BOMInputStream(fis, enc);
enc = uin.getCharset(); // check and skip possible BOM bytes
| 构造器和说明 |
|---|
BOMInputStream(InputStream in) |
BOMInputStream(InputStream in,
String defaultCharset) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
String |
getCharset() |
String |
getDefaultCharset() |
protected void |
init()
Read-ahead four bytes and check for BOM marks.
|
int |
read() |
available, mark, markSupported, read, read, reset, skippublic BOMInputStream(InputStream in)
public BOMInputStream(InputStream in, String defaultCharset)
public String getDefaultCharset()
public String getCharset()
public void close()
throws IOException
close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在类中 InputStreamIOExceptionpublic int read()
throws IOException
read 在类中 InputStreamIOExceptionprotected void init()
throws IOException
IOException - 读取引起的异常Copyright © 2020. All rights reserved.