Here you can find the source of bytesToIntLE(byte[] bytes, int offset, int length)
Parameter | Description |
---|---|
bytes | the byte sequence that is to be converted. |
offset | the offset to bytes at which the sequence starts. |
length | the length of the byte sequence. |
private static int bytesToIntLE(byte[] bytes, int offset, int length)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w .ja v a2 s.com * Converts a little-endian sequence of bytes to an {@code int}. * * @param bytes the byte sequence that is to be converted. * @param offset the offset to {@code bytes} at which the sequence starts. * @param length the length of the byte sequence. * @return the {@code int} that results from the conversion of the byte sequence. * @since 1.0 * @see #bytesToIntBE(byte[], int, int) * @see #intToBytesLE(int, byte[], int, int) */ private static int bytesToIntLE(byte[] bytes, int offset, int length) { int i = offset + length; int value = bytes[--i]; while (--i >= offset) { value <<= 8; value |= bytes[i] & 0xFF; } return value; } }