- All Implemented Interfaces:
java.io.Closeable
, java.lang.AutoCloseable
public class UnicodeInputStream
extends java.io.InputStream
This inputstream will recognize unicode BOM marks
and will skip bytes if getEncoding() method is called
before any of the read(...) methods. Invoking read methods
without first calling getEncoding will not skip BOM mark.
Usage pattern:
String enc = "ISO-8859-1"; // or put NULL to use systemdefault
FileInputStream fis = new FileInputStream(file);
UnicodeInputStream uin = new UnicodeInputStream(fis, enc);
enc = uin.getEncoding(); // check for BOM mark and skip bytes
InputStreamReader in;
if (enc == null) in = new InputStreamReader(uin);
else in = new InputStreamReader(uin, enc);