ConvertDataTypes.comConvert data types programming in one click !

Convert byte[] to int in Java

    3948 hits
  • byte[] vInt = new byte[] {
  • (byte)(2147483647 >>> 24),
  • (byte)(2147483647 >>> 16),
  • (byte)(2147483647 >>> 8),
  • (byte)2147483647};
  • int vOut = (vInt[0] << 24)
  • + ((vInt[1] & 0xFF) << 16)
  • + ((vInt[2] & 0xFF) << 8)
  • + (vInt[3] & 0xFF);