Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.nio.ByteBuffer;

public class Main {
    /**
     * Converts an array of 4 bytes into a int.
     *
     * @param bytes The bytes.
     * @return The int.
     */
    public static int bytesToInt(final byte[] bytes) {
        final ByteBuffer buffer = ByteBuffer.allocate(4);
        buffer.put(bytes, 0, 4);
        buffer.flip();
        return buffer.getInt();
    }
}