Here you can find the source of copyFile(String srFile, String dtFile)
public static void copyFile(String srFile, String dtFile)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void copyFile(String srFile, String dtFile) { try {/*from w ww .j a v a 2s . c o m*/ File f1 = new File(srFile); File f2 = new File(dtFile); InputStream in = new FileInputStream(f1); OutputStream out = new FileOutputStream(f2); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } catch (FileNotFoundException ex) { System.err.println(ex.getMessage() + " in the specified directory."); System.exit(0); } catch (IOException e) { System.out.println(e.getMessage()); } } }