Here you can find the source of copyFile(File src, File dest)
public static void copyFile(File src, File dest) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /* www . j av a2s . c o m*/ *******************************************************************************/ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /** * Copy file from src (path to the original file) to dest (path to the * destination file). */ public static void copyFile(File src, File dest) throws IOException { InputStream in = null; OutputStream out = null; byte[] buffer = new byte[12 * 1024]; int read; try { in = new FileInputStream(src); try { out = new FileOutputStream(dest); while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } finally { if (out != null) { out.close(); } } } finally { if (in != null) { in.close(); } } } }