Here you can find the source of copyFile(String src, String dest)
modelled on example from http://javaalmanac.com/, which says "All the code examples from the book are made available here for you to copy and paste into your programs."
static public void copyFile(String src, String dest) throws IOException
//package com.java2s; // This software is published under the terms of the MIT license, a copy import java.io.*; public class Main { /** modelled on example from http://javaalmanac.com/, which says "All the code examples from the book are made available here for you to copy and paste into your programs." */ static public void copyFile(String src, String dest) throws IOException { if (!new File(src).exists()) { return; }//from w ww . ja v a 2 s . co m InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dest); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } }