Here you can find the source of copyFileAndReName(String destPath, String srcPath, String srcFile, String destFile)
public static void copyFileAndReName(String destPath, String srcPath, String srcFile, String destFile) throws IOException
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void copyFileAndReName(String destPath, String srcPath, String srcFile, String destFile) throws IOException { (new File(destPath)).mkdirs(); File file = new File(srcPath + srcFile); if (file.exists()) { FileInputStream input = new FileInputStream(file); FileOutputStream output = new FileOutputStream(destPath + "/" + destFile); byte[] b = new byte[1024 * 5]; int len; while ((len = input.read(b)) != -1) { output.write(b, 0, len); }/* w ww. ja va 2s. c o m*/ output.flush(); output.close(); input.close(); } } }