Here you can find the source of copyFile(String src, String dst)
static public void copyFile(String src, String dst) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { static public void copyFile(String src, String dst) throws IOException { FileOutputStream fos = null; FileInputStream fis = null; try {//w w w.j ava 2 s .c o m fos = new FileOutputStream(dst); fis = new FileInputStream(src); byte[] buf = new byte[4096]; int nread = fis.read(buf); while (nread > 0) { fos.write(buf, 0, nread); nread = fis.read(buf); } } catch (IOException e) { File f = new File(dst); if (f.exists()) { f.delete(); } throw e; } finally { if (fis != null) { try { fis.close(); } catch (Exception e) { } } if (fos != null) { try { fos.close(); } catch (Exception e) { } } } } static public boolean exists(String path) { File f = new File(path); return f.exists(); } }