Java Write Byte Array to File writeFile(File file, byte[] context, boolean append)

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

Description

write File

License

Apache License

Declaration

public static void writeFile(File file, byte[] context, boolean append) throws IOException 

Method Source Code


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

import java.io.*;

public class Main {

    public static void writeFile(File file, byte[] context, boolean append) throws IOException {
        FileOutputStream fos = null;

        if (!file.getParentFile().exists()) {
            file.getParentFile().mkdirs();
        } else if (append) {
            fos = new FileOutputStream(file, append);
        }/*from   w  w w . j  a v  a2 s  .c o  m*/
        if (fos == null) {
            fos = new FileOutputStream(file);
        }
        fos.write(context);
        fos.close();
    }

    public static void writeFile(File file, byte[] context) throws IOException {
        writeFile(file, context, false);
    }
}

Related

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