public static int parseInt(byte[] b, int offset, int length, int base) {
		int value = 0;

		//CHECKSTYLE:OFF
		if (length < 0) {
			length = b.length - offset;
		}
		//CHECKSTYLE:ON

		for (int i = 0; i < length; i++) {
			char c = (char) (_0XFF & b[offset + i]);

			int digit = c - '0';
			if (digit < 0 || digit >= base || digit >= TEN) {
				digit = TEN + c - 'A';
				if (digit < TEN || digit >= base) {
					digit = TEN + c - 'a';
				}
			}
			if (digit < 0 || digit >= base) {
				throw new NumberFormatException(new String(b, offset, length));
			}
			value = value * base + digit;
		}
		return value;
	}
public static int parseInt ( byte [ ] b , int offset , int length , int base ) { int value = 0 ; if ( length < 0 ) { length = b . length - offset ; } for ( int i = 0 ; i < length ; i ++ ) { char c = ( char ) ( _0XFF & b [ offset + i ] ) ; int digit = c - '0' ; if ( digit < 0 || digit >= base || digit >= TEN ) { digit = TEN + c - 'A' ; if ( digit < TEN || digit >= base ) { digit = TEN + c - 'a' ; } } if ( digit < 0 || digit >= base ) { throw new NumberFormatException ( new String ( b , offset , length ) ) ; } value = value * base + digit ; } return value ; }
Parse an int from a byte array of ascii characters. Negative numbers are
not handled.

@param b      byte array
@param offset Offset within string
@param length Length of integer or -1 for remainder of string
@param base   base of the integer
@return the parsed integer
@throws NumberFormatException if the array cannot be parsed into an integer