Here you can find the source of getInt(byte[] buf, int pos, boolean bigEndian)
Parameter | Description |
---|---|
buf | the source byte array |
pos | the position of array to convert from |
bigEndian | true if big endian, false if little endian |
public static final int getInt(byte[] buf, int pos, boolean bigEndian)
//package com.java2s; public class Main { /**//from w w w . j a va 2 s. c om * Convert byte sequence into java short from first 4 bytes * * @param buf the source byte array * @param bigEndian true if big endian, false if little endian * @return short the java short */ public static final int getInt(byte[] buf, boolean bigEndian) { return getInt(buf, 0, bigEndian); } /** * Convert byte sequence into java int. * * @param buf the source byte array * @param pos the position of array to convert from * @param bigEndian true if big endian, false if little endian * @return short the java int */ public static final int getInt(byte[] buf, int pos, boolean bigEndian) { if (bigEndian) { return ((buf[pos] & 0xff) << 24) | ((buf[pos + 1] & 0xff) << 16) | ((buf[pos + 2] & 0xff) << 8) | (buf[pos + 3] & 0xff); } else { return ((buf[pos + 3] & 0xff) << 24) | ((buf[pos + 2] & 0xff) << 16) | ((buf[pos + 1] & 0xff) << 8) | (buf[pos] & 0xff); } } }