Package de.hybris.bootstrap.xml
Class UnicodeInputStream
java.lang.Object
java.io.InputStream
de.hybris.bootstrap.xml.UnicodeInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
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);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclose()Read encoding based on BOM mark and skip bytes.protected voidinit()Read-ahead four bytes and check for BOM marks.booleanintread()voidsetSkipBOM(boolean b) Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
UnicodeInputStream
-
-
Method Details
-
isBOMSkipped
public boolean isBOMSkipped() -
setSkipBOM
public void setSkipBOM(boolean b) -
getDefaultEncoding
-
getEncoding
Read encoding based on BOM mark and skip bytes. All non-mark bytes are unread back to the stream. -
init
Read-ahead four bytes and check for BOM marks. Extra bytes are unread back to the stream, only BOM bytes are skipped.- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-