Here you can find the source of writeFile(String targetPath, String filename, byte[] content)
public static boolean writeFile(String targetPath, String filename, byte[] content)
//package com.java2s; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; public class Main { public static boolean writeFile(String targetPath, String filename, byte[] content) { boolean ok = false; if (content != null && targetPath != null && targetPath.length() > 0 && filename != null && filename.length() > 0) { BufferedOutputStream bos = null; if (!targetPath.endsWith(File.separator)) { targetPath += File.separator; }//from w w w . j a va 2s. c o m try { FileOutputStream fos; fos = new FileOutputStream(new File(targetPath + filename)); bos = new BufferedOutputStream(fos); bos.write(content); bos.flush(); ok = true; } catch (Exception e) { e.printStackTrace(); } finally { if (bos != null) { try { bos.close(); } catch (Exception e) { } } } } return ok; } }