Here you can find the source of writeFile(File file, byte[]... data)
Parameter | Description |
---|---|
file | - The file to write in. |
data | - The byte array, or list of byte arrays to write. |
public static void writeFile(File file, byte[]... data)
//package com.java2s; //License from project: Apache License import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; public class Main { /**//from w w w . j a va2 s.co m * Takes a byte array, or list of byte arrays, and writes them into a file. This method replaces any current data, with the new * data provided by the byte array. Using a list of byte arrays will combine the bytes arrays into a single byte array as it writes * them. * @param file - The file to write in. * @param data - The byte array, or list of byte arrays to write. */ public static void writeFile(File file, byte[]... data) { if (data == null) return; BufferedOutputStream out = null; try { out = new BufferedOutputStream(new FileOutputStream(file)); for (byte[] d : data) out.write(d); } catch (Exception exception) { exception.printStackTrace(); } finally { if (out != null) { try { out.close(); } catch (Exception exception) { exception.printStackTrace(); } } } } }