Java FileInputStream Copy copyFile(File sourceFile, File destFile)

Here you can find the source of copyFile(File sourceFile, File destFile)

Description

copy File

License

Open Source License

Declaration

public static void copyFile(File sourceFile, File destFile) 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;

public class Main {
    public static void copyFile(File sourceFile, File destFile) throws IOException {
        FileInputStream inStream = new FileInputStream(sourceFile);
        try {/*w w  w.  j a  v a2 s  .c om*/
            FileOutputStream outStream = new FileOutputStream(destFile);
            try {
                inStream.getChannel().transferTo(0, sourceFile.length(), outStream.getChannel());
            } finally {
                outStream.close();
            }
        } finally {
            inStream.close();
        }
    }
}

Related

  1. copyFile(File sourceDir, File destDir, String filename)
  2. copyFile(File sourceFile, File destDir)
  3. copyFile(File sourceFile, File destFile)
  4. copyFile(File sourceFile, File destFile)
  5. copyFile(File sourceFile, File destFile)
  6. copyFile(File sourceFile, File destFile)
  7. copyFile(File sourceFile, File destFile)
  8. copyFile(File sourceFile, File destFile, boolean overwrite, boolean preserveLastModified)
  9. copyFile(File sourceFile, File destinationFile)