public class UnicodeDetectingInputStream
extends java.io.InputStream
This is recorded as This Sun JVM bug.
This inputstream will recognize unicode BOM marks and will skip bytes if getEncoding() method is called before any of the read(...) methods. The source is taken from here with minor changes.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
UTF_16_BE |
static java.lang.String |
UTF_16_LE |
static java.lang.String |
UTF_32_BE |
static java.lang.String |
UTF_32_LE |
static java.lang.String |
UTF_8 |
static byte[] |
UTF16BE_BOM |
static byte[] |
UTF16LE_BOM |
static byte[] |
UTF32BE_BOM |
static byte[] |
UTF32LE_BOM |
static byte[] |
UTF8_BOM |
Constructor and Description |
---|
UnicodeDetectingInputStream(java.io.InputStream in,
java.lang.String defaultEnc) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
java.lang.String |
getDefaultEncoding() |
java.lang.String |
getEncoding() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
public static final java.lang.String UTF_16_LE
public static final java.lang.String UTF_16_BE
public static final java.lang.String UTF_8
public static final java.lang.String UTF_32_LE
public static final java.lang.String UTF_32_BE
public static final byte[] UTF8_BOM
public static final byte[] UTF16LE_BOM
public static final byte[] UTF16BE_BOM
public static final byte[] UTF32LE_BOM
public static final byte[] UTF32BE_BOM
public UnicodeDetectingInputStream(java.io.InputStream in, java.lang.String defaultEnc)
public java.lang.String getDefaultEncoding()
public java.lang.String getEncoding()
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 read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException