Here you can find the source of copyFile(String source, String dest)
public static void copyFile(String source, String dest) throws IOException
//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(String source, String dest) throws IOException { copyFile(new File(source), new File(dest)); }/*w w w .j a va 2 s . c o m*/ public static void copyFile(File source, File dest) throws IOException { InputStream input = null; OutputStream output = null; try { input = new FileInputStream(source); output = new FileOutputStream(dest); byte[] buf = new byte[1024]; int bytesRead; while ((bytesRead = input.read(buf)) > 0) { output.write(buf, 0, bytesRead); } } finally { if (input != null) input.close(); if (output != null) output.close(); } } }