Java Byte Array to Int bytesToInt(byte[] buf, int startIdx)

Here you can find the source of bytesToInt(byte[] buf, int startIdx)

Description

bytes To Int

License

Apache License

Declaration

public static int bytesToInt(byte[] buf, int startIdx) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int bytesToInt(byte[] buf) {
        return ((0xff & buf[0]) << 24) | ((0xff & buf[1]) << 16) | ((0xff & buf[2]) << 8) | (0xff & buf[3]);
    }/*from   w  w  w. j  a  v  a 2s.c  om*/

    public static int bytesToInt(byte[] buf, int startIdx) {
        return ((0xff & buf[startIdx]) << 24) | ((0xff & buf[startIdx + 1]) << 16)
                | ((0xff & buf[startIdx + 2]) << 8) | (0xff & buf[startIdx + 3]);
    }
}

Related

  1. bytesToInt(byte[] b)
  2. bytesToInt(byte[] b, int i)
  3. bytesToInt(byte[] b, int offset)
  4. bytesToInt(byte[] b, int offset)
  5. bytesToInt(byte[] buf, int offset)
  6. bytesToInt(byte[] buff, int off, int len)
  7. bytesToInt(byte[] bytes)
  8. bytesToInt(byte[] bytes)
  9. bytesToInt(byte[] bytes)