Java FileOutputStream Write saveFile(byte[] fileData, String outputDir, String fileName)

Here you can find the source of saveFile(byte[] fileData, String outputDir, String fileName)

Description

save File

License

Open Source License

Declaration

public static String saveFile(byte[] fileData, String outputDir, String fileName) throws Exception 

Method Source Code


//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;
    }
}

Related

  1. saveContentToFile(DataHandler content, File outFile)
  2. saveData(byte[] data, String PATH, String fileName)
  3. saveDataToFile(String filePath, byte[] data)
  4. saveDownloadedFile(InputStream is, String destination)
  5. saveEntry(String destPath, ZipEntry target, ZipFile zf)
  6. saveFile(File f, InputStream stream)
  7. saveFile(File f, String fileName, File desDir)
  8. saveFile(File f, String fileName, File desDir)
  9. saveFile(File file, byte[] contenido)