Class ContentTypeDetectingInputStreamWrapper

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
org.openpdf.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

  • Field Details

    • MAGIC_BYTES_PDF

      private static final byte[] MAGIC_BYTES_PDF
    • MAX_MAGIC_BYTES

      private static final int MAX_MAGIC_BYTES
      See Also:
    • NO_DATA

      private static final byte[] NO_DATA
    • firstBytes

      private final byte[] firstBytes
  • Constructor Details

  • Method Details

    • readFirstBytes

      private static byte[] readFirstBytes(InputStream in, int count) throws IOException
      Throws:
      IOException
    • streamStartsWithMagicBytes

      private boolean streamStartsWithMagicBytes(byte[] bytes)
    • isPdf

      public boolean isPdf()