Android IntBuffer to ByteBuffer Convert copyIntBufferAsByteBuffer( IntBuffer paramIntBuffer)

Here you can find the source of copyIntBufferAsByteBuffer( IntBuffer paramIntBuffer)

Description

copy Int Buffer As Byte Buffer

Declaration

public static ByteBuffer copyIntBufferAsByteBuffer(
            IntBuffer paramIntBuffer) 

Method Source Code

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

import java.nio.IntBuffer;

public class Main {
    public static ByteBuffer copyIntBufferAsByteBuffer(
            IntBuffer paramIntBuffer) {
        ByteBuffer localByteBuffer = newByteBuffer(paramIntBuffer
                .remaining() * 4);/*from   ww w  . j a  v a 2s . c o m*/
        paramIntBuffer.mark();
        localByteBuffer.asIntBuffer().put(paramIntBuffer);
        paramIntBuffer.reset();
        localByteBuffer.rewind();
        return localByteBuffer;
    }

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