Java FileOutputStream Create writeFile(String filePath, byte[] bytes)

Here you can find the source of writeFile(String filePath, byte[] bytes)

Description

Writes given bytes to the file

License

Open Source License

Parameter

Parameter Description
filePath a parameter
bytes a parameter

Declaration

public static void writeFile(String filePath, byte[] bytes) 

Method Source Code


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

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

public class Main {
    /**//from   ww w.j  a v a 2  s . c o  m
     * Writes given bytes to the file
     *
     * @param filePath
     * @param bytes
     */
    public static void writeFile(String filePath, byte[] bytes) {
        try (FileOutputStream fos = new FileOutputStream(filePath)) {
            fos.write(bytes);
        } catch (IOException ex) {
            System.out.println("Error writing file: " + ex.toString());
        }
    }
}

Related

  1. writeFile(String f, String s)
  2. writeFile(String file, byte[]... data)
  3. writeFile(String file, byte[]... data)
  4. writeFile(String fileName)
  5. writeFile(String fileOutput, byte[] data)
  6. writeFile(String filePath, Object obj)
  7. writeFile(String filePathName, Object obj)
  8. writeFile(String p_filename, String p_buffer)
  9. writeFile(String path, byte[] contents)