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
public class ContentTypeDetectingInputStreamWrapper extends BufferedInputStream
This class wraps an input stream and detects if it contains certain content using "magic numbers". ...currently only pdf detection is implemented
- Author:
- mwyraz
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]MAGIC_BYTESprotected static byte[]MAGIC_BYTES_PDFprotected static intMAX_MAGIC_BYTES-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description ContentTypeDetectingInputStreamWrapper(InputStream source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisPdf()protected booleanstreamStartsWithMagicBytes(byte[] bytes)-
Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, read, read, reset, skip
-
Methods inherited from class java.io.FilterInputStream
read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Field Detail
-
MAX_MAGIC_BYTES
protected static final int MAX_MAGIC_BYTES
- See Also:
- Constant Field Values
-
MAGIC_BYTES
protected final byte[] MAGIC_BYTES
-
MAGIC_BYTES_PDF
protected static final byte[] MAGIC_BYTES_PDF
-
-
Constructor Detail
-
ContentTypeDetectingInputStreamWrapper
public ContentTypeDetectingInputStreamWrapper(InputStream source) throws IOException
- Throws:
IOException
-
-