Java FileInputStream Copy copyFile(File orig, File dest)

Here you can find the source of copyFile(File orig, File dest)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File orig, File dest) throws IOException 

Method Source Code

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    public static void copyFile(File orig, File dest) throws IOException {
        FileInputStream fis = new FileInputStream(orig);
        FileOutputStream fos = new FileOutputStream(dest);
        copyData(fis, fos);//from  w w  w.  j  a v a 2s  .  c o m

    }

    public static void copyData(InputStream fis, OutputStream fos) throws IOException {
        try {
            byte[] buff = new byte[50000];
            int readed = -1;
            while ((readed = fis.read(buff)) > 0) {
                fos.write(buff, 0, readed);
            }
        } finally {
            fis.close();
            fos.close();
        }
    }
}

Related

  1. copyFile(File inputFile, File outputFile)
  2. copyFile(File inputFile, OutputStream os)
  3. copyFile(File of, File nf)
  4. copyFile(File oldFile, File newFile)
  5. copyFile(File oldFile, String newPath)
  6. copyFile(File orig, File dest, boolean overwrite)
  7. copyFile(File original, File copy)
  8. copyFile(File original, File destination)
  9. copyFile(File original, File parent)