Here you can find the source of copyFile(String sourceFilePath, String destinationFilePath)
private static void copyFile(String sourceFilePath, String destinationFilePath) throws IOException
//package com.java2s; 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 { private static void copyFile(String sourceFilePath, String destinationFilePath) throws IOException { InputStream inStream = null; OutputStream outStream = null; File sourceFile = new File(sourceFilePath); File destinationFile = new File(destinationFilePath); inStream = new FileInputStream(sourceFile); outStream = new FileOutputStream(destinationFile); // for override file content // outStream = new FileOutputStream(file2,<strong>true</strong>); // for append file content byte[] buffer = new byte[1024]; int length; while ((length = inStream.read(buffer)) > 0) { outStream.write(buffer, 0, length); }/*from w w w. j av a 2 s.c om*/ if (inStream != null) { inStream.close(); } if (outStream != null) { outStream.close(); } } }