Here you can find the source of copyFile(String src, String dst)
public static void copyFile(String src, String dst) throws Exception
//package com.java2s; /******************************************************************************* * Copyright ? 2012-2015 eBay Software Foundation * This program is dual licensed under the MIT and Apache 2.0 licenses. * Please see LICENSE for more information. *******************************************************************************/ import java.io.BufferedReader; import java.io.FileOutputStream; import java.io.FileReader; import java.io.PrintWriter; public class Main { /**//from ww w . ja v a2 s. com * Copy a text file */ public static void copyFile(String src, String dst) throws Exception { BufferedReader inFile = null; PrintWriter outFile = null; String line; // Read in & Write out try { inFile = new BufferedReader(new FileReader(src)); outFile = new PrintWriter(new FileOutputStream(dst)); while ((line = inFile.readLine()) != null) outFile.println(line); } finally { if (inFile != null) inFile.close(); if (outFile != null) outFile.close(); } } }