Here you can find the source of toFile(File file, byte[] data)
Parameter | Description |
---|---|
file | File to turn into byte[] |
data | contents of file |
public static void toFile(File file, byte[] data)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/*from ww w . j a v a2 s . c o m*/ * Outputs some arbitrary data to file on disk * * @param file File to turn into byte[] * @param data contents of file */ public static void toFile(File file, byte[] data) { System.out.println("Attempt create file " + file.getAbsolutePath()); File parent = file.getParentFile(); parent.mkdirs(); //TODO use Box class and do checksum, or shall we? BufferedOutputStream outputStream = null; try { outputStream = new BufferedOutputStream(new FileOutputStream(file)); outputStream.write(data); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (outputStream != null) { try { outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } } }