Here you can find the source of copyFile(String oldFile, String newFile)
public static void copyFile(String oldFile, String newFile) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; public class Main { public static void copyFile(String oldFile, String newFile) throws Exception { File file1 = new File(oldFile); int byteRead; FileOutputStream fs = new FileOutputStream(newFile); InputStream inputStream = new FileInputStream(file1); byte[] buffer = new byte[1024]; while ((byteRead = inputStream.read(buffer)) != -1) { fs.write(buffer, 0, byteRead); }// ww w. ja v a 2 s .c o m fs.close(); inputStream.close(); } }