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

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

Description

Convenience method to save a file

License

Open Source License

Parameter

Parameter Description
fileName a parameter

Declaration

public static void saveFile(String fileName, byte[] data) 

Method Source Code

//package com.java2s;

import java.io.FileOutputStream;

import java.io.OutputStream;

public class Main {
    /**//from w  ww  .  j a va2s  .c  om
     * Convenience method to save a file
     * @param fileName
     */
    public static void saveFile(String fileName, byte[] data) {
        try {
            OutputStream out = new FileOutputStream(fileName);
            out.write(data);
            out.close();
        } catch (Exception e) {
            System.out.println("Cannot save file. " + e.getMessage());
        }
        System.out.println("Have save file of: " + data.length + " bytes.");
    }
}

Related

  1. saveFile(String destinationFile, String contents)
  2. saveFile(String dir, String fileName, String data)
  3. saveFile(String file, String text)
  4. saveFile(String fileName, byte[] bytes)
  5. saveFile(String filename, byte[] content)
  6. saveFile(String fileName, InputStream stream)
  7. saveFile(String filename, String content)
  8. saveFile(String fileName, String contents)
  9. saveFile(String name, byte[] data)