Java Byte Array to Int bytesToInt(byte[] buff, int off, int len)

Here you can find the source of bytesToInt(byte[] buff, int off, int len)

Description

Utility methods for working with bytes and byte buffers

License

Apache License

Declaration

public static int bytesToInt(byte[] buff, int off, int len) 

Method Source Code

//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    /**/* w  ww  .  j av a 2s  .  c  om*/
     * Utility methods for working with bytes and byte buffers
     */
    public static int bytesToInt(byte[] buff, int off, int len) {
        int num = 0;

        int shift = 0;
        for (int i = off + len - 1; i >= off; i--) {

            num += (buff[i] & 0xFF) << shift;
            shift += 8;
        }

        return num;
    }
}

Related

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