Here you can find the source of copyFile(File of, File nf)
public static boolean copyFile(File of, File nf)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static boolean copyFile(File of, File nf) { InputStream in;//from ww w .ja v a 2s . com try { in = new FileInputStream(of); OutputStream out = new FileOutputStream(nf); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); return false; } catch (IOException e) { e.printStackTrace(); return false; } return true; } }