Java FileOutputStream Write Byte Array writeBytes(File f, byte[] b)

Here you can find the source of writeBytes(File f, byte[] b)

Description

write Bytes

License

Apache License

Declaration

public static boolean writeBytes(File f, byte[] b) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {

    public static boolean writeBytes(String fileName, byte[] b) {
        return writeBytes(new File(fileName), b);
    }/*  w ww . j  ava2s.c om*/

    public static boolean writeBytes(File f, byte[] b) {
        BufferedOutputStream bos = null;
        try {
            bos = new BufferedOutputStream(new FileOutputStream(f));
            bos.write(b);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        } finally {
            if (bos != null) {
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

Related

  1. writeBytes(byte[] bytes, String file)
  2. writeBytes(byte[] data, File file)
  3. writeBytes(File aFile, byte theBytes[])
  4. writeBytes(File dest, byte[] data, int off, int len, boolean append)
  5. writeBytes(File f, byte[] data)
  6. writeBytes(File file, byte[] arr)
  7. writeBytes(File file, byte[] ba)
  8. writeBytes(File file, byte[] bytes)