Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

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

public class Main {
    public static final int BYTES_PER_SHORT = 2;

    public static short[] byteToShortArray(byte[] data) {
        short[] shorts = new short[data.length / BYTES_PER_SHORT];
        ByteBuffer.wrap(data).order(ByteOrder.nativeOrder()).asShortBuffer().get(shorts);
        return shorts;
    }
}