Here you can find the source of toInt(byte[] input)
Parameter | Description |
---|---|
input | A network byte-ordered representation of an int . |
public static int toInt(byte[] input)
//package com.java2s; //License from project: BSD License public class Main { /**/* w w w. jav a 2s .c o m*/ * Converts a given byte array to an {@code int}. Bytes are expected in * network byte order. * * @param input A network byte-ordered representation of an {@code int}. * @return The {@code int} value represented by the input array. */ public static int toInt(byte[] input) { assert input.length == 4 : "toInt(): Byte array length must be 4."; int output = 0; output = ((input[0] & 0xff) << 24) | ((input[1] & 0xff) << 16) | ((input[2] & 0xff) << 8) | (input[3] & 0xff); return output; } }