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;

import java.nio.ShortBuffer;

public class Main {
    /**
     * 
     * @since 1.0.0
     * @param v
     * @return the ShortBuffer
     */
    public static ShortBuffer toShortBuffer(short[] v) {
        ByteBuffer buf = ByteBuffer.allocateDirect(v.length * 2);
        buf.order(ByteOrder.nativeOrder());
        ShortBuffer buffer = buf.asShortBuffer();
        buffer.put(v);
        buffer.position(0);
        return buffer;
    }
}