Here you can find the source of writeFile(String filename, byte[] bs)
Parameter | Description |
---|---|
filename | a parameter |
bs | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static void writeFile(String filename, byte[] bs) throws Exception
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /**/*from w w w .j ava2 s .c o m*/ * write bytes to file * * @param filename * @param bs * @throws IOException */ public static void writeFile(String filename, byte[] bs) throws Exception { try { final File file = new File(filename).getParentFile(); if (!file.exists()) { file.mkdirs(); } final FileOutputStream out = new FileOutputStream(filename); out.write(bs); out.flush(); out.close(); } catch (IOException e) { throw new Exception("writeFile error", e); } } }