Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static int bytes2int(byte[] bytes, int index) {
        if (null == bytes || bytes.length < (4 + index)) {
            throw new RuntimeException("bytes of int error");
        }

        return (int) ((((bytes[index + 3] & 0xff) << 24) | ((bytes[index + 2] & 0xff) << 16)
                | ((bytes[index + 1] & 0xff) << 8) | ((bytes[index] & 0xff) << 0)));
    }
}