Convert byte Array To Int by offset - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Convert byte Array To Int by offset

Demo Code


//package com.java2s;

public class Main {
    public static int byteArrayToInt(byte[] b, int offset) {
        int value = 0;
        for (int i = 0; i < 4; i++) {
            int shift = (4 - 1 - i) * 8;
            value += (b[i + offset] & 0x000000FF) << shift;
        }/*from   ww  w . j a  v a 2  s .co  m*/
        return value;
    }
}

Related Tutorials