Here you can find the source of copyFile(String sourcefile, String targetfile)
public static void copyFile(String sourcefile, String targetfile)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void copyFile(String sourcefile, String targetfile) { InputStream inStream = null; OutputStream outStream = null; try {// ww w.j av a 2 s.c om File afile = new File(sourcefile); File bfile = new File(targetfile); inStream = new FileInputStream(afile); outStream = new FileOutputStream(bfile); byte[] buffer = new byte[1024]; int length; while ((length = inStream.read(buffer)) > 0) { outStream.write(buffer, 0, length); } inStream.close(); outStream.close(); } catch (IOException e) { e.printStackTrace(); } } }