public class BOMAwareInputStream extends InputStream implements AutoCloseable
| Constructor and Description |
|---|
BOMAwareInputStream(InputStream input,
String defaultEncoding)
Creates a new BOMAwareInputStream object for a given InputStream and a given
default encoding.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
autoDtected()
Indicates if the guessed encoding was auto-detected.
|
void |
close()
WARNING: The input
InputStream will also be closed when this
method is called. |
String |
detectEncoding()
Tries to detect the presence of a Byte-Order-Mark.
|
int |
getBOMSize()
Gets the number of bytes used by the Byte-Order-mark in this document.
|
String |
getDetectedEncoding()
Gets the encoding that was guessed.
|
boolean |
hasUTF8BOM()
Indicates if the guessed encoding is UTF-8 and this file has a BOM.
|
int |
read() |
available, mark, markSupported, read, read, reset, skippublic BOMAwareInputStream(InputStream input, String defaultEncoding)
input - The input stream to use.defaultEncoding - The default encoding to use if none can be auto-detected.public String detectEncoding() throws IOException
IOException - if an I/O error occurs.public String getDetectedEncoding()
public boolean autoDtected()
public int getBOMSize()
public boolean hasUTF8BOM()
public int read()
throws IOException
read in class InputStreamIOExceptionpublic void close()
throws IOException
InputStream will also be closed when this
method is called.close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionCopyright © 2022. All rights reserved.