public static void main(String[] args) {
byte[] buffer = new byte[4];
buffer[0] = 0;
buffer[1] = 0;
buffer[2] = 1;
buffer[3] = 1;
int messageLength = ((buffer[0] & 0xff) << 24)
| ((buffer[1] & 0xff) << 16) | ((buffer[2] & 0xff) << 8)
| (buffer[3] & 0xff);
System.out.println(messageLength);
}