Here you can find the source of copyFile(String sourceFilePath, String destinationFilePath)
public static void copyFile(String sourceFilePath, String destinationFilePath) 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 sourceFilePath, String destinationFilePath) throws IOException { InputStream in = null;//w w w .ja va 2 s. c o m OutputStream out = null; try { in = new FileInputStream(new File(sourceFilePath)); out = new FileOutputStream(new File(destinationFilePath)); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } finally { try { if (in != null) { in.close(); } } catch (IOException ex) { } try { if (out != null) { out.close(); } } catch (IOException ex) { } } } }