Android Byte Array Save to File writeBytes(File file, boolean append, byte[] bytes)

Here you can find the source of writeBytes(File file, boolean append, byte[] bytes)

Description

write bytes into file

Parameter

Parameter Description
file a parameter
append a parameter
bytes a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static void writeBytes(File file, boolean append, byte[] bytes)
        throws IOException 

Method Source Code

//package com.java2s;

import java.io.File;

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

public class Main {
    /**/* w  w  w .  j  a va  2s .c o m*/
     * write bytes into file
     * @param file
     * @param append
     * @param bytes
     * @throws IOException
     */
    public static void writeBytes(File file, boolean append, byte[] bytes)
            throws IOException {
        if (bytes.length == 0)
            return;

        FileOutputStream output = new FileOutputStream(file, append);
        output.write(bytes);
        output.flush();
        output.close();
    }
}

Related

  1. copy(byte[] input, OutputStream output)
  2. copy(byte[] input, Writer output)
  3. copy(byte[] input, Writer output, String encoding)
  4. saveBytes(@NotNull File file, @NotNull byte[] bytes)
  5. saveFile(byte[] data, String fileName)
  6. writeBytes(byte[] bytes, File file, boolean append)
  7. writeFile(String fileName, byte[] content)
  8. writeFile(String fileName, byte[] datas, boolean overwrite)
  9. writeFile(String path, String fileName, byte[] datas, boolean overwrite)