public class UnicodeInputStream
extends java.io.InputStream
Modifier and Type | Field and Description |
---|---|
static byte[] |
BOM_UTF16_BE |
static byte[] |
BOM_UTF16_LE |
static byte[] |
BOM_UTF32_BE |
static byte[] |
BOM_UTF32_LE |
static byte[] |
BOM_UTF8 |
static int |
MAX_BOM_SIZE |
Constructor and Description |
---|
UnicodeInputStream(java.io.InputStream in,
java.lang.String targetEncoding)
Creates new unicode stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes input stream.
|
int |
getBOMSize()
Returns BOM size in bytes.
|
java.lang.String |
getDetectedEncoding()
Returns detected UTF encoding or
null if no UTF encoding has been detected (i.e. no BOM). |
protected void |
init()
Detects and decodes encoding from BOM character.
|
int |
read()
Reads byte from the stream.
|
public static final int MAX_BOM_SIZE
public static final byte[] BOM_UTF32_BE
public static final byte[] BOM_UTF32_LE
public static final byte[] BOM_UTF8
public static final byte[] BOM_UTF16_BE
public static final byte[] BOM_UTF16_LE
public UnicodeInputStream(java.io.InputStream in, java.lang.String targetEncoding)
Detect mode is active when target encoding is not specified. In detect mode, it tries to detect encoding from BOM if exist. If BOM doesn't exist, encoding is not detected.
Read mode is active when target encoding is set. Then this stream reads optional BOM for given encoding. If BOM doesn't exist, nothing is skipped.
public java.lang.String getDetectedEncoding()
null
if no UTF encoding has been detected (i.e. no BOM).
If stream is not read yet, it will be initalized
first.protected void init() throws java.io.IOException
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int getBOMSize()
-1
if BOM not found.Copyright © 2003-present Jodd Team