Java FileOutputStream Write saveFile(String path, byte[] content)

Here you can find the source of saveFile(String path, byte[] content)

Description

save File

License

Open Source License

Declaration

public static void saveFile(String path, byte[] content) throws IOException 

Method Source Code


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

import java.io.ByteArrayInputStream;

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

public class Main {
    public static void saveFile(String path, byte[] content) throws IOException {
        try {/*w w  w  . j a  v a 2s. c  o m*/
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(content);
            try (OutputStream outputStream = new FileOutputStream(path)) {
                int data;
                while ((data = byteArrayInputStream.read()) != -1) {
                    outputStream.write(data);
                }
            }
        } catch (IOException e) {
            throw e;
        }
    }
}

Related

  1. saveFile(String fileName, byte[] data)
  2. saveFile(String fileName, InputStream stream)
  3. saveFile(String filename, String content)
  4. saveFile(String fileName, String contents)
  5. saveFile(String name, byte[] data)
  6. saveFile(String pathFile, String data)
  7. saveFile(String pathname, String fileName, String contents)
  8. saveFile(String pathRoot, String subPath, boolean isFoler, InputStream in)
  9. saveFile(String text, File saveFile)