Here you can find the source of getInt(byte[] buffer, int pos, int count)
Parameter | Description |
---|---|
buffer | a parameter |
pos | a parameter |
count | a parameter |
public static int getInt(byte[] buffer, int pos, int count)
//package com.java2s; public class Main { /**/*from w w w . java 2 s . c o m*/ * Get integer? * @param buffer * @param pos * @param count * @return */ public static int getInt(byte[] buffer, int pos, int count) { int ret = 0; for (int i = 0; i < 4 && i < count && (i + pos) < buffer.length; i++) { ret *= 256; ret += toUnsignedInteger(buffer[i + pos]); } return ret; } /** * Convert byte to unsigned integer. * @param b * @return */ public static int toUnsignedInteger(byte b) { int n = b >= 0 ? b : b + 256; return n; } }