Java FileOutputStream Create writeFile(InputStream is, File outFile)

Here you can find the source of writeFile(InputStream is, File outFile)

Description

write File

License

Open Source License

Declaration

public static void writeFile(InputStream is, File outFile) throws IOException 

Method Source Code


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

import java.io.*;

public class Main {
    public static void writeFile(InputStream is, File outFile) throws IOException {
        BufferedOutputStream bos = null;
        try {//from  w  ww .  j  a  v  a 2 s  . c  o  m
            bos = new BufferedOutputStream(new FileOutputStream(outFile));
            byte[] buffer = new byte[4096];
            int len;
            BufferedInputStream bis = new BufferedInputStream(is);
            while ((len = bis.read(buffer)) != -1) {
                bos.write(buffer, 0, len);
            }
        } finally {
            if (bos != null) {
                bos.close();
            }
        }
    }

    public static void writeFile(byte[] buffer, File outFile) throws IOException {
        BufferedOutputStream bos = null;
        try {
            bos = new BufferedOutputStream(new FileOutputStream(outFile));
            bos.write(buffer);
        } finally {
            if (bos != null) {
                bos.close();
            }
        }
    }
}

Related

  1. writeFile(final String fileNamePath, final byte[] daten)
  2. writeFile(InputStream in, File file)
  3. writeFile(InputStream inputFile, String path, String fullFileName)
  4. writeFile(InputStream inputStream, String filename, long lastModified)
  5. writeFile(InputStream is, File file)
  6. writeFile(InputStream srcStream, File destFile)
  7. writeFile(InputStream stream, File to)
  8. writeFile(List data, String filename)
  9. writeFile(String directoryPath, String filename, byte[] bytes)