Java Byte Array Save to File fileDump(String fileName, byte[] data)

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

Description

Writes a large byte array to a file.

License

Open Source License

Parameter

Parameter Description
fileName output file name
data target data

Declaration

public static final void fileDump(String fileName, byte[] data) 

Method Source Code

//package com.java2s;
/*//w ww . java  2  s  .  c  o m
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */

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

public class Main {
    /**
     * Writes a large byte array to a file.
     *
     * @param fileName output file name
     * @param data target data
     */
    public static final void fileDump(String fileName, byte[] data) {
        try {
            FileOutputStream os = new FileOutputStream(fileName);
            os.write(data);
            os.close();
        }

        catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}