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

Here you can find the source of writeFile(byte[] data, String fileName)

Description

write File

License

Open Source License

Declaration

public static void writeFile(byte[] data, String fileName)
            throws IOException 

Method Source Code

//package com.java2s;
/*/* w  w  w .  j  a  v a 2 s.  co  m*/
 * (C) 2007-2012 Alibaba Group Holding Limited.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 * Authors:
 *   leiwen <chrisredfield1985@126.com> , boyan <killme2008@gmail.com>
 */

import java.io.File;

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

import java.io.OutputStream;

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

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

Related

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