类 UnicodeBOMInputStream

java.lang.Object
java.io.InputStream
org.glavo.chardet.UnicodeBOMInputStream
所有已实现的接口:
Closeable, AutoCloseable

public class UnicodeBOMInputStream extends InputStream
The UnicodeBOMInputStream class wraps any InputStream and detects the presence of any Unicode BOM (Byte Order Mark) at its beginning, as defined by RFC 3629 - UTF-8, a transformation format of ISO 10646

The Unicode FAQ defines 5 types of BOMs:

  • 00 00 FE FF  = UTF-32, big-endian
  • FF FE 00 00  = UTF-32, little-endian
  • FE FF        = UTF-16, big-endian
  • FF FE        = UTF-16, little-endian
  • EF BB BF     = UTF-8

Use the getBOM() method to know whether a BOM has been detected or not.

Use the skipBOM() method to remove the detected BOM from the wrapped InputStream object.

  • 构造器详细资料

    • UnicodeBOMInputStream

      public UnicodeBOMInputStream(InputStream inputStream) throws IOException
      Constructs a new UnicodeBOMInputStream that wraps the specified InputStream. By default, skip BOM bytes.
      参数:
      inputStream - an InputStream.
      抛出:
      NullPointerException - when inputStream is null.
      IOException - on reading from the specified InputStream when trying to detect the Unicode BOM.
    • UnicodeBOMInputStream

      public UnicodeBOMInputStream(InputStream inputStream, boolean skipIfFound) throws IOException
      Constructs a new UnicodeBOMInputStream that wraps the specified InputStream.
      参数:
      inputStream - an InputStream.
      skipIfFound - to automatically skip BOM bytes if found
      抛出:
      NullPointerException - when inputStream is null.
      IOException - on reading from the specified InputStream when trying to detect the Unicode BOM.
    • UnicodeBOMInputStream

      public UnicodeBOMInputStream(InputStream inputStream, boolean skipIfFound, boolean useMark) throws IOException
      Constructs a new UnicodeBOMInputStream that wraps the specified InputStream.
      参数:
      inputStream - an InputStream.
      skipIfFound - to automatically skip BOM bytes if found
      useMark - to select whether to call the mark/reset of the inputStream
      抛出:
      NullPointerException - when inputStream is null.
      IOException - on reading from the specified InputStream when trying to detect the Unicode BOM.
  • 方法详细资料