Java FileOutputStream Write saveBytes(File f, byte[] content)

Here you can find the source of saveBytes(File f, byte[] content)

Description

save Bytes

License

LGPL

Declaration

public static void saveBytes(File f, byte[] content) throws IOException 

Method Source Code

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

import java.io.ByteArrayInputStream;

import java.io.File;

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

public class Main {
    private static final int BUF_SIZE = 65536;

    public static void saveBytes(File f, byte[] content) throws IOException {
        FileOutputStream os = null;
        ByteArrayInputStream bais = null;
        try {/*from   ww  w  .  j a v  a2  s  . c o m*/
            os = new FileOutputStream(f);
            bais = new ByteArrayInputStream(content);
            byte[] buf = new byte[BUF_SIZE];
            while (true) {
                int rc = bais.read(buf);
                if (rc <= 0)
                    break;
                else
                    os.write(buf, 0, rc);
            }
        } finally {
            if (os != null)
                os.close();
            if (bais != null)
                bais.close();
        }
    }
}

Related

  1. saveBinaryFile(String fileName, byte[] buffer)
  2. saveByteArrayToFile(final File file, final byte[] array)
  3. saveByteFile(byte[] data, String filePath)
  4. saveBytes(byte[] b, File destFolder, String fileName, String suffix)
  5. saveBytes(byte[] bytes, File file)
  6. saveBytes(File file, byte[] bytes)
  7. saveBytes(String filename, byte[] byteData)
  8. saveBytes(String filename, byte[] bytes)
  9. saveBytes(String filename, byte[] data)