Code example for ByteArrayInputStream

Methods: read

0
    public final int batchNo;
    public final int weekProd;
    public final int yearProd;
 
    public DesfireManufacturingData (byte[] data) {
        ByteArrayInputStream stream = new ByteArrayInputStream(data);
        hwVendorID     = stream.read();
        hwType         = stream.read();
        hwSubType      = stream.read();
        hwMajorVersion = stream.read();
        hwMinorVersion = stream.read();
        hwStorageSize  = stream.read();
        hwProtocol     = stream.read();
 
        swVendorID     = stream.read();
        swType         = stream.read();
        swSubType      = stream.read();
        swMajorVersion = stream.read();
        swMinorVersion = stream.read();
        swStorageSize  = stream.read();
        swProtocol     = stream.read();
 
        // FIXME: This has fewer digits than what's contained in EXTRA_ID, why? 
        byte[] buf = new byte[7];
        stream.read(buf, 0, buf.length);
        uid = Utils.byteArrayToInt(buf);
 
        // FIXME: This is returning a negative number. Probably is unsigned. 
        buf = new byte[5];
        stream.read(buf, 0, buf.length);
        batchNo = Utils.byteArrayToInt(buf);
 
        // FIXME: These numbers aren't making sense. 
        weekProd = stream.read();
        yearProd = stream.read();
    } 
 
    public static DesfireManufacturingData fromXml (Element element) {
        return new DesfireManufacturingData(element);
    }