Package org.xhtmlrenderer.util
Class ContentTypeDetectingInputStreamWrapper
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
org.xhtmlrenderer.util.ContentTypeDetectingInputStreamWrapper
- All Implemented Interfaces:
Closeable
,AutoCloseable
This class wraps an input stream and detects if it contains certain content using "magic numbers".
...
currently only pdf detection is implemented
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
private static final byte[]
protected static final int
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
isPdf()
private boolean
streamStartsWithMagicBytes
(byte[] bytes) Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, read, read, reset, skip, transferTo
Methods inherited from class java.io.FilterInputStream
read
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes
-
Field Details
-
MAX_MAGIC_BYTES
protected static final int MAX_MAGIC_BYTES- See Also:
-
firstBytes
private final byte[] firstBytes -
MAGIC_BYTES_PDF
private static final byte[] MAGIC_BYTES_PDF
-
-
Constructor Details
-
ContentTypeDetectingInputStreamWrapper
- Throws:
IOException
-
-
Method Details
-
streamStartsWithMagicBytes
private boolean streamStartsWithMagicBytes(byte[] bytes) -
isPdf
public boolean isPdf()
-