Java Convert via ByteBuffer toFloatBytes(List datas)

Here you can find the source of toFloatBytes(List datas)

Description

to Float Bytes

License

Open Source License

Declaration

public static byte[] toFloatBytes(List<Double> datas) 

Method Source Code

//package com.java2s;
/**/* w  w w  .  ja v a2  s . c  om*/
 * Copyright (C) 2014 Bnome SPRL (info@bnome.be)
 *
 * This file is part of VectionVR Stabilizer library.
 *
 * VectionVR Stabilizer library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * VectionVR Stabilizer library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with VectionVR Stabilizer library.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.nio.ByteBuffer;
import static java.nio.ByteBuffer.allocate;
import java.util.List;

public class Main {
    public static byte[] toFloatBytes(List<Double> datas) {
        ByteBuffer buf = allocate(48);
        for (Double data : datas) {
            buf.putFloat(data.floatValue());
        }
        buf.flip();
        return buf.array();
    }
}

Related

  1. toFile(URL url)
  2. toFiles(URL[] urls)
  3. toFloat(byte[] bytes)
  4. toFloat(final byte[] b)
  5. toFloatArray(int[] intArray)
  6. toGuidBytes(UUID theUuid)
  7. toGuidString(UUID uuid)
  8. toHex(byte[] bytes)
  9. toHexBytes(byte[] bytes)