Java File Write via ByteBuffer writeFC(String fname, float[] res)

Here you can find the source of writeFC(String fname, float[] res)

Description

write FC

License

Apache License

Declaration

public static void writeFC(String fname, float[] res) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.*;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.channels.FileChannel;

public class Main {
    public static void writeFC(String fname, float[] res) throws IOException {
        new File(fname).createNewFile();
        ByteBuffer bbuffer = ByteBuffer.allocate(4 * res.length);
        FloatBuffer buffer = bbuffer.asFloatBuffer();
        for (int i = 0; i < res.length; i++)
            buffer.put(res[i]);/*  w  ww  .jav a  2  s . c  o  m*/
        buffer.flip();
        FileChannel fc = new RandomAccessFile(fname, "rw").getChannel();
        fc.write(bbuffer);
        fc.close();
    }
}

Related

  1. writeComment(File zipFile, String comment)
  2. writeDataLengthsToHeader(FileOutputStream fpo)
  3. writeDelimitedToOutputStream(byte[] bytes, OutputStream outputStream)
  4. writeDouble(BufferedWriter bw, double[] buf)
  5. writeEmpty()
  6. writeFile(File file, byte[] bytes)
  7. writeFile(File file, byte[] data)
  8. writeFile(String source, File outputFile)
  9. writeFileAsByteArray(File file, byte[] par2Data)