Java FileOutputStream Write saveByteFile(byte[] data, String filePath)

Here you can find the source of saveByteFile(byte[] data, String filePath)

Description

save Byte File

License

Open Source License

Declaration

public static void saveByteFile(byte[] data, String filePath) throws IllegalArgumentException, IOException 

Method Source Code

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

import java.io.*;

public class Main {
    public static void saveByteFile(byte[] data, File file) throws IllegalArgumentException, IOException {
        if (!file.getParentFile().exists() && !mkDirs(file)) {
            throw new IllegalArgumentException("Could not create file folder.");
        }/*from   ww w .jav  a2s.c  om*/
        FileOutputStream saveFile = new FileOutputStream(file);
        saveFile.write(data);
        saveFile.close();
    }

    public static void saveByteFile(byte[] data, String filePath) throws IllegalArgumentException, IOException {
        saveByteFile(data, new File(filePath));
    }

    public static boolean mkDirs(File file) {
        if (file.isDirectory())
            return file.mkdirs();
        return file.getParentFile().mkdirs();
    }
}

Related

  1. saveArray(byte[] pictureBytes, OutputStream stream)
  2. saveBase64Str2Disk(String base64Str, File file)
  3. saveBase64strToFile(String base64Str, String filePath)
  4. saveBinaryFile(String fileName, byte[] buffer)
  5. saveByteArrayToFile(final File file, final byte[] array)
  6. saveBytes(byte[] b, File destFolder, String fileName, String suffix)
  7. saveBytes(byte[] bytes, File file)
  8. saveBytes(File f, byte[] content)
  9. saveBytes(File file, byte[] bytes)