Android FloatBuffer to ByteBuffer Convert copyFloatBufferAsByteBuffer( FloatBuffer paramFloatBuffer)

Here you can find the source of copyFloatBufferAsByteBuffer( FloatBuffer paramFloatBuffer)

Description

copy Float Buffer As Byte Buffer

Declaration

public static ByteBuffer copyFloatBufferAsByteBuffer(
            FloatBuffer paramFloatBuffer) 

Method Source Code

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

import java.nio.FloatBuffer;

public class Main {
    public static ByteBuffer copyFloatBufferAsByteBuffer(
            FloatBuffer paramFloatBuffer) {
        ByteBuffer localByteBuffer = newByteBuffer(paramFloatBuffer
                .remaining() * 4);// w  w  w  .  j a va  2  s. c  o  m
        paramFloatBuffer.mark();
        localByteBuffer.asFloatBuffer().put(paramFloatBuffer);
        paramFloatBuffer.reset();
        localByteBuffer.rewind();
        return localByteBuffer;
    }

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