Here you can find the source of bytesToInt(byte[] array, int offset)
Parameter | Description |
---|---|
array | The array of bytes. |
offset | The offset from which to start unmarshalling. |
public static int bytesToInt(byte[] array, int offset)
//package com.java2s; /*/*w w w .ja va 2 s . c o m*/ * %W% %E% * * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { /** Unmarshal a byte array to an integer. Assume the bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+3] is the least-significant-byte. @param array The array of bytes. @param offset The offset from which to start unmarshalling. */ public static int bytesToInt(byte[] array, int offset) { int b1, b2, b3, b4; b1 = (array[offset++] << 24) & 0xFF000000; b2 = (array[offset++] << 16) & 0x00FF0000; b3 = (array[offset++] << 8) & 0x0000FF00; b4 = (array[offset++] << 0) & 0x000000FF; return (b1 | b2 | b3 | b4); } }