Here you can find the source of saveFile(byte[] fileData, String outputDir, String fileName)
public static String saveFile(byte[] fileData, String outputDir, String fileName) throws Exception
//package com.java2s; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; public class Main { public static String saveFile(byte[] fileData, String outputDir, String fileName) throws Exception { String path = outputDir + "/" + fileName; File outFile = new File(path); if (!outFile.getParentFile().exists()) { outFile.getParentFile().mkdirs(); }/*from w w w.jav a2 s. c o m*/ if (!outFile.exists()) { outFile.createNewFile(); } OutputStream os = new FileOutputStream(outFile); os.write(fileData); os.close(); return path; } }