Code example for DataInputStream

Methods: read, readInt

0
    public boolean isValidMagicHeader() { 
        return Arrays.equals(MAGIC_HEADER, magic);
    } 
 
    public static SnappyCodec readHeader(InputStream in) throws IOException {
        DataInputStream d = new DataInputStream(in);
        byte[] magic = new byte[MAGIC_LEN];
        d.read(magic, 0, MAGIC_LEN);
        int version = d.readInt();
        int compatibleVersion = d.readInt();
        return new SnappyCodec(magic, version, compatibleVersion);
    } 
 
    public static SnappyCodec currentHeader() { 
        return new SnappyCodec(MAGIC_HEADER, DEFAULT_VERSION, MINIMUM_COMPATIBLE_VERSION);
    } 
 
}