Java Byte Array to Int bytesToInt(byte[] bytes, int offset, int length)

Here you can find the source of bytesToInt(byte[] bytes, int offset, int length)

Description

bytes To Int

License

Open Source License

Declaration

private static int bytesToInt(byte[] bytes, int offset, int length) 

Method Source Code

//package com.java2s;
/**/*from w ww . j  av a2  s.c o  m*/
 * Copyright (c) 2010-2015, openHAB.org and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    private static int bytesToInt(byte[] bytes, int offset, int length) {
        int value = 0;
        for (int i = 0; i < length; i++) {
            value |= ((int) (bytes[offset + i] & 0xff) << (8 * i));
        }
        return value;
    }
}

Related

  1. bytesToInt(byte[] bytes)
  2. bytesToInt(byte[] bytes)
  3. bytesToInt(byte[] bytes)
  4. bytesToInt(byte[] bytes, int bitOffset, int bitCount)
  5. bytesToInt(byte[] bytes, int offset)
  6. bytesToInt(byte[] bytes, int start)
  7. bytesToInt(byte[] bytesSource)
  8. bytesToInt(byte[] data)
  9. bytesToInt(byte[] data)