Here you can find the source of copyFile(String from, String to)
public static boolean copyFile(String from, String to)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static boolean copyFile(String from, String to) { File fromFile, toFile;/*from ww w . j av a 2 s . co m*/ fromFile = new File(from); toFile = new File(to); FileInputStream fis = null; FileOutputStream fos = null; try { toFile.createNewFile(); fis = new FileInputStream(fromFile); fos = new FileOutputStream(toFile); int bytesRead; byte[] buf = new byte[4 * 1024]; while ((bytesRead = fis.read(buf)) != -1) { fos.write(buf, 0, bytesRead); } fos.flush(); fos.close(); fis.close(); } catch (Exception e) { return false; } return true; } }