Java Write Byte Array to File writeFile(byte[] content, String filename)

Here you can find the source of writeFile(byte[] content, String filename)

Description

write File

License

Open Source License

Declaration

public static void writeFile(byte[] content, String filename) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    private static String SERVER_PATH = "C:\\Java\\web\\uploadFile\\";

    public static void writeFile(byte[] content, String filename) throws IOException {

        File file = new File(SERVER_PATH + filename);

        if (!file.exists()) {
            file.createNewFile();/* w w w. j ava 2  s  .co m*/
        }

        FileOutputStream fop = new FileOutputStream(file);

        fop.write(content);
        fop.flush();
        fop.close();
    }
}

Related

  1. writeFile(byte[] buf, File file)
  2. writeFile(byte[] bytes, File file)
  3. writeFile(byte[] bytes, File file)
  4. writeFile(byte[] bytes, File file)
  5. writeFile(byte[] bytes, String path)
  6. writeFile(byte[] content, String filename)
  7. writeFile(byte[] data, File file)
  8. writeFile(byte[] data, File outFile)
  9. writeFile(byte[] data, String fileName)