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()
获取BOM头中的编码
|
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)
in - 流public BOMInputStream(InputStream in, String defaultCharset)
in - 流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 © 2022. All rights reserved.