Here you can find the source of copyFile(String sourcefile, String targetFile)
public static void copyFile(String sourcefile, String targetFile) throws IOException
//package com.java2s; /**// w w w . j av a 2s. co m * WebStorm APICloud plugin * Copyright (c) 2014-2015 by APICloud, Inc. All Rights Reserved. * Licensed under the terms of the GNU Public License (GPL) v3. * Please see the license.html included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ 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 { public static void copyFile(String sourcefile, String targetFile) throws IOException { File sourceFile = new File(sourcefile); if (sourceFile.exists()) { copyFile(sourceFile, new File(targetFile)); } } public static void copyFile(File sourcefile, File targetFile) throws IOException { OutputStream out; InputStream in; in = new FileInputStream(sourcefile); out = new FileOutputStream(targetFile, true); //append byte[] b = new byte[1024]; //block read to improve performance int temp = 0; while ((temp = in.read()) != -1) { out.write(b, 0, temp); } in.close(); out.close(); } }