Here you can find the source of copyFile(String src, String dst)
static public boolean copyFile(String src, String dst)
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class Main { static public boolean copyFile(String src, String dst) { if (src == null || dst == null) { return false; }/* w w w . j a va 2s .c om*/ return writeTextToFile(getTextFromFile(src), dst); } public static boolean writeTextToFile(String text, String filename) { if (text == null || filename == null) { return false; } try { PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF8")); pw.print(text); pw.close(); return true; } catch (Exception e) { e.printStackTrace(); } return false; } public static String getTextFromFile(String filename) { try { StringBuilder sb = new StringBuilder(); BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(filename), "UTF-8")); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } catch (Exception e) { e.printStackTrace(); } return null; } }