Java Write Byte Array to File writeFile(File f, byte[] data)

Here you can find the source of writeFile(File f, byte[] data)

Description

write File

License

Open Source License

Declaration

public static void writeFile(File f, byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.OutputStream;
import java.io.RandomAccessFile;

public class Main {
    public static void writeFile(File f, byte[] data) {
        try {//from www  .j  a v a  2  s  .com
            RandomAccessFile raf = new RandomAccessFile(f, "rw");
            try {
                raf.write(data);
            } finally {
                raf.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void writeFile(byte[] data, String fileName) throws IOException {
        OutputStream out = new FileOutputStream(fileName);
        out.write(data);
        out.close();
    }
}

Related

  1. writeFile(byte[] data, String fileName)
  2. writeFile(byte[] data, String filePath)
  3. writeFile(byte[] data, String path, boolean overwrite)
  4. writeFile(byte[] fileData, String path)
  5. writeFile(byte[] outputBytes, String outputFile)
  6. writeFile(File file, byte[] b)
  7. writeFile(File file, byte[] content)
  8. writeFile(File file, byte[] context, boolean append)
  9. writeFile(File file, byte[] data)