Here you can find the source of copyFile(File source, File dest)
public static boolean copyFile(File source, File dest)
//package com.java2s; /*/*from ww w.j av a 2 s . co m*/ Copyright 2009 Semantic Discovery, Inc. (www.semanticdiscovery.com) This file is part of the Semantic Discovery Toolkit. The Semantic Discovery Toolkit is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. The Semantic Discovery Toolkit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with The Semantic Discovery Toolkit. If not, see <http://www.gnu.org/licenses/>. */ import java.io.*; public class Main { public static boolean copyFile(File source, File dest) { boolean result = true; FileInputStream in = null; FileOutputStream out = null; final byte[] buffer = new byte[32768]; // 32K buffer try { in = new FileInputStream(source); out = new FileOutputStream(dest); while (true) { final int n = in.read(buffer); if (n < 0) break; out.write(buffer, 0, n); } } catch (IOException e) { // failed to copy result = false; } finally { try { if (in != null) in.close(); if (out != null) out.close(); } catch (IOException e) { // failed to close result = false; } } return result; } }