Android ShortBuffer Copy copyShortBuffer(ShortBuffer paramShortBuffer)

Here you can find the source of copyShortBuffer(ShortBuffer paramShortBuffer)

Description

copy Short Buffer

Declaration

public static ShortBuffer copyShortBuffer(ShortBuffer paramShortBuffer) 

Method Source Code

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

import java.nio.ShortBuffer;

public class Main {
    public static ShortBuffer copyShortBuffer(ShortBuffer paramShortBuffer) {
        return copyShortBufferAsByteBuffer(paramShortBuffer)
                .asShortBuffer();/*from  w w  w.j  a  va  2  s .c o m*/
    }

    public static ByteBuffer copyShortBufferAsByteBuffer(
            ShortBuffer paramShortBuffer) {
        ByteBuffer localByteBuffer = newByteBuffer(paramShortBuffer
                .remaining() * 2);
        paramShortBuffer.mark();
        localByteBuffer.asShortBuffer().put(paramShortBuffer);
        paramShortBuffer.reset();
        localByteBuffer.rewind();
        return localByteBuffer;
    }

    public static ByteBuffer newByteBuffer(int paramInt) {
        ByteBuffer localByteBuffer = ByteBuffer.allocateDirect(paramInt);
        localByteBuffer.order(ByteOrder.nativeOrder());
        return localByteBuffer;
    }
}