Here you can find the source of copyFile(final String sourceFile, final String destinationFile)
public static void copyFile(final String sourceFile, final String destinationFile) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 eBay Inc. 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 * * Contributors:// www . ja v a 2s . c o m * eBay Inc. - initial API and implementation *******************************************************************************/ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** This does a binary file copy */ public static void copyFile(final String sourceFile, final String destinationFile) throws IOException { final FileInputStream fis = new FileInputStream(sourceFile); final FileOutputStream fos = new FileOutputStream(destinationFile); try { final byte[] buffer = new byte[4096]; int numBytesRead; do { numBytesRead = fis.read(buffer); if (numBytesRead > 0) { fos.write(buffer, 0, numBytesRead); } } while (numBytesRead >= 0); } finally { try { fos.flush(); } finally { try { fos.close(); } finally { fis.close(); } } } } }