Java BufferedInputStream Copy copyFileNormal(File copyFrom, File copyTo)

Here you can find the source of copyFileNormal(File copyFrom, File copyTo)

Description

copy File Normal

License

Open Source License

Declaration

public static boolean copyFileNormal(File copyFrom, File copyTo) throws IOException 

Method Source Code


//package com.java2s;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;

import java.io.File;
import java.io.FileInputStream;

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

public class Main {

    public static boolean copyFileNormal(File copyFrom, File copyTo) throws IOException {
        if (!copyFrom.exists() || copyTo == null) {
            return false;
        }/*from ww w  . ja v  a2s  . c o m*/

        byte[] arrayOfByte = new byte[4096];
        BufferedInputStream input = new BufferedInputStream(new FileInputStream(copyFrom));
        BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(copyTo, false));
        int i;
        while ((i = input.read(arrayOfByte, 0, arrayOfByte.length)) != -1) {
            output.write(arrayOfByte, 0, i);
        }
        output.close();
        input.close();
        return true;
    }
}

Related

  1. copyFile(String sourceFilePath, String destinationFilePath)
  2. copyFile(String src, String dest)
  3. copyFileBytes(String srcFileName, String tarFileName)
  4. copyFileFromStream(InputStream in, File dest)
  5. copyFileFromZipToDir(String zipFile, String fileNamePattern, File dir)
  6. copyFileToFile(File in, File out)
  7. copyFileToStream(File from, OutputStream out)
  8. copyFileToStream(File input, OutputStream os)
  9. copyFileToTemp(InputStream is, String dirName, String fileName)