Code example for InputStream

Methods: mark, read, reset

0
            markable = is;
        } 
             
        // Read the signature from the stream and then reset it back 
        try { 
            markable.mark(MAX_BYTES_IN_SIGNATURE);
 
            byte[] signature = new byte[MAX_BYTES_IN_SIGNATURE];
            markable.read(signature, 0, MAX_BYTES_IN_SIGNATURE);
            markable.reset();
 
            if ((signature[0] & 0xFF) == 0xFF &&
                    (signature[1] & 0xFF) == 0xD8 &&
                    (signature[2] & 0xFF) == 0xFF) { // JPEG
                return loadDecoder(PNG_DECODER, src, is);
            } else if ((signature[0] & 0xFF) == 0x47 && // G
                    (signature[1] & 0xFF) == 0x49 && // I
                    (signature[2] & 0xFF) == 0x46) { // F
                return loadDecoder(GIF_DECODER, src, is);
            } else if ((signature[0] & 0xFF) == 137 && // PNG signature: 137 80 78 71 13 10 26 10
                    (signature[1] & 0xFF) == 80 &&