Here you can find the source of copyFile(String src, String to)
public static int copyFile(String src, String to)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static int copyFile(String src, String to) { return copyFile(new File(src), new File(to)); }/* www .j ava2 s .c o m*/ public static int copyFile(File in, File out) { try { FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out); byte[] buf = new byte[1024]; int i = 0; while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); } fis.close(); fos.close(); fis = null; fos = null; } catch (Exception e) { System.err.println(e); return -1; } return 1; } }