Java FileInputStream Copy copyFile(File in, File out)

Here you can find the source of copyFile(File in, File out)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File in, File out) throws Exception 

Method Source Code


//package com.java2s;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Main {
    public static void copyFile(File in, File out) throws Exception {
        FileInputStream fis = new FileInputStream(in);
        FileOutputStream fos = new FileOutputStream(out);
        try {//from  w ww  . j  a v  a2  s. co  m
            byte[] buf = new byte[1024];
            int i = 0;
            while ((i = fis.read(buf)) != -1) {
                fos.write(buf, 0, i);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            if (fis != null)
                fis.close();
            if (fos != null)
                fos.close();
        }
    }
}

Related

  1. copyFile(File in, File out)
  2. copyFile(File in, File out)
  3. copyFile(File in, File out)
  4. copyFile(File in, File out)
  5. copyFile(File in, File out)
  6. copyFile(File inFile, File outFile)
  7. copyFile(File inFile, File outFile)
  8. copyFile(File input, File output)
  9. copyFile(File inputFile, File outputFile)