Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static int byteArrayToShort(byte[] bytes) {
        return byteArrayToShort(bytes, 0);
    }

    public static int byteArrayToShort(byte[] bytes, int offset) {
        ByteBuffer bb = ByteBuffer.wrap(bytes);
        bb.order(ByteOrder.LITTLE_ENDIAN);
        return bb.getShort(offset);
    }
}