Here you can find the source of copyFile(String input, String output)
public static void copyFile(String input, String output)
//package com.java2s; /*/* www. j ava 2 s . com*/ * Copyright 2002 - 2013 Pentaho Corporation. All rights reserved. * * This software was developed by Pentaho Corporation and is provided under the terms * of the Mozilla Public License, Version 1.1, or any later version. You may not use * this file except in compliance with the license. If you need a copy of the license, * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. TThe Initial Developer is Pentaho Corporation. * * Software distributed under the Mozilla Public License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to * the license for the specific language governing your rights and limitations. */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static void copyFile(String input, String output) { try { File inputFile = new File(input); File outputFile = new File(output); if (inputFile.exists() && !inputFile.getCanonicalPath().equals(outputFile.getCanonicalPath())) { FileInputStream fis = new FileInputStream(inputFile); FileOutputStream fos = new FileOutputStream(outputFile); fos.getChannel().transferFrom(fis.getChannel(), 0, fis.getChannel().size()); fos.close(); fis.close(); } } catch (Exception e) { e.printStackTrace(System.err); } } }