Java FileInputStream Copy copyFile(String f1, String f2)

Here you can find the source of copyFile(String f1, String f2)

Description

copy f1 to f2

License

Open Source License

Parameter

Parameter Description
f1 a parameter
f2 a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static void copyFile(String f1, String f2) throws Exception 

Method Source Code

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

import java.io.FileInputStream;

import java.io.FileOutputStream;

public class Main {
    /**/*from   w  w  w.ja v a  2 s .c o m*/
     * copy f1 to f2
     * @param f1
     * @param f2
     * @throws Exception
     */
    public static void copyFile(String f1, String f2) throws Exception {
        FileInputStream is = new FileInputStream(f1);
        FileOutputStream f = new FileOutputStream(f2);
        byte[] b = new byte[1024];
        int m = is.read(b);
        while (m != -1) {
            f.write(b, 0, m);
            m = is.read(b);
        }
        f.close();
    }
}

Related

  1. copyFile(final String sSource, final String sDest)
  2. copyFile(InputStream in, File dst)
  3. copyFile(InputStream in, File to)
  4. copyFile(InputStream in, String destFile)
  5. copyFile(OutputStream out, InputStream in)
  6. copyFile(String fileIn, String fileOut)
  7. copyFile(String fileInName, String fileOutName)
  8. copyFile(String fileName, String fromDir, String toDir)
  9. copyFile(String fileOutPut, String fileIn)