Java BufferedInputStream Copy copyFile(File src, File dest)

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

Description

Insert the method's description here.

License

Open Source License

Parameter

Parameter Description
src java.io.File
dest java.io.File

Declaration

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

Method Source Code


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

import java.io.*;

public class Main {
    /**//from   w w w  .  j a va2  s .  c om
     * Insert the method's description here.
     * Creation date: (30.01.01 09:22:29)
     * @param src java.io.File
     * @param dest java.io.File
     */
    public static void copyFile(File src, File dest) throws IOException {
        InputStream ss = null;
        OutputStream ds = null;
        try {
            ss = new BufferedInputStream(new FileInputStream(src));
            ds = new BufferedOutputStream(new FileOutputStream(dest));
            copyStream(ss, ds);
        } finally {
            if (ds != null) {
                ds.close();
            }
            if (ss != null) {
                ss.close();
            }
        }
    }

    /**
     * Insert the method's description here.
     * Creation date: (30.01.01 09:22:29)
     * @param src java.io.File
     * @param dest java.io.File
     */
    public static void copyStream(InputStream src, OutputStream dest) throws IOException {
        int c;
        while ((c = src.read()) != -1) {
            dest.write(c);
        }
    }
}

Related

  1. copyFile(File source, File target)
  2. copyFile(File source, File target)
  3. copyFile(File sourceFile, File targetFile)
  4. copyFile(File sourceFile, File targetFile)
  5. copyFile(File sourceFile, File targetFile)
  6. copyFile(File src, File dest)
  7. copyFile(File src, File dest)
  8. copyFile(File src, File dest)
  9. copyFile(File src, File dst)