Package net.sourceforge.pmd.util
Class IOUtil.BomAwareInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- net.sourceforge.pmd.util.IOUtil.BomAwareInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Enclosing class:
- IOUtil
public static class IOUtil.BomAwareInputStream extends FilterInputStream
Input stream that skips an optional byte order mark at the beginning of the stream. Whether the stream had a byte order mark (encoded in either UTF-8, UTF-16LE or UTF-16BE) can be checked with
hasBom()
. The corresponding charset can be retrieved withgetBomCharsetName()
.If the stream didn't had a BOM, then no bytes are skipped.
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description BomAwareInputStream(InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBomCharsetName()
boolean
hasBom()
int
read()
int
read(byte[] b, int off, int len)
-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
BomAwareInputStream
public BomAwareInputStream(InputStream in)
-
-
Method Detail
-
read
public int read() throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
hasBom
public boolean hasBom()
-
getBomCharsetName
public String getBomCharsetName()
-
-