Here you can find the source of copyFileToFile(File input, String outputPath, String exportName)
public static File copyFileToFile(File input, String outputPath, String exportName)
//package com.java2s; //License from project: LGPL import java.io.BufferedOutputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static File copyFileToFile(File input, String outputPath, String exportName) {/*from w ww . j av a2 s. c om*/ File file = new File(outputPath, exportName); try { DataOutputStream out = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(file))); // Transfer bytes from in to out FileInputStream is = new FileInputStream(input); byte[] buf = new byte[1024]; int len; while ((len = is.read(buf)) > 0) { out.write(buf, 0, len); } is.close(); out.close(); } catch (IOException e) { e.printStackTrace(); System.err.println("Error Writing/Reading Streams."); } return file; } }