Java BufferedInputStream Copy copyFile(InputStream is, File newFile)

Here you can find the source of copyFile(InputStream is, File newFile)

Description

Copia de um ImputStream para um Arquivo a ser criado no caminho pathFileDestign

License

Open Source License

Parameter

Parameter Description
is a parameter
pathFileDestign a parameter

Exception

Parameter Description
FileNotFoundException an exception
IOException an exception

Declaration

public static boolean copyFile(InputStream is, File newFile) throws FileNotFoundException, IOException 

Method Source Code


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

import java.io.*;

public class Main {
    /**/*www . ja  v a 2s .c o m*/
     * Copia de um ImputStream para um Arquivo a ser criado no caminho
     * pathFileDestign
     *
     * @param is
     * @param pathFileDestign
     * @return
     * @throws FileNotFoundException
     * @throws IOException
     */
    public static boolean copyFile(InputStream is, File newFile) throws FileNotFoundException, IOException {
        FileOutputStream out = new FileOutputStream(newFile);
        BufferedInputStream inBuffer = new BufferedInputStream(is);
        BufferedOutputStream outBuffer = new BufferedOutputStream(out);
        int theByte = 0;

        while ((theByte = inBuffer.read()) > -1) {
            outBuffer.write(theByte);
        }

        outBuffer.close();
        inBuffer.close();
        out.close();
        is.close();
        return true;
    }
}

Related

  1. copyFile(final File source, final File destination)
  2. copyFile(final File source, final File destination, final boolean overwrite)
  3. copyFile(final File sourceFile, final File targetFile)
  4. copyFile(final File src, final File dest)
  5. copyFile(final File to, final File from)
  6. copyFile(InputStream src, File dest)
  7. copyFile(InputStream src, File dst)
  8. copyFile(String dest_path, String src_path)
  9. copyFile(String fileName, File sourceRoot, File targetRoot, Set copied)