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

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

Description

write File

License

Open Source License

Declaration

public static void writeFile(File file, byte[] data) throws IOException 

Method Source Code


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

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

public class Main {
    public static void writeFile(File file, byte[] data) throws IOException {
        FileOutputStream os = new FileOutputStream(file);
        try {//from w w w.  j a  v  a  2s.  c o  m
            os.write(data);
        } finally {
            os.close();
        }
    }

    public static void writeFile(File file, String text, String enc) throws IOException {
        writeFile(file, text.getBytes(enc));
    }

    public static void writeFile(File file, String text) throws IOException {
        writeFile(file, text, "utf-8");
    }
}

Related

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