Here you can find the source of copyFile(File in, File out)
public static void copyFile(File in, File out) throws IOException
//package com.java2s; /*/* w w w . j a va2s. co m*/ * Stage - Spatial Toolbox And Geoscript Environment * (C) HydroloGIS - www.hydrologis.com * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * (http://www.eclipse.org/legal/epl-v10.html). */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void copyFile(String fromFile, String toFile) throws IOException { File in = new File(fromFile); File out = new File(toFile); copyFile(in, out); } public static void copyFile(File in, File out) throws IOException { FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out); byte[] buf = new byte[1024]; int i = 0; while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); } fis.close(); fos.close(); } }