Here you can find the source of copyFile(File oldFile, String newPath)
private static boolean copyFile(File oldFile, String newPath)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static boolean copyFile(File oldFile, String newPath) { if (!oldFile.exists() || !oldFile.isFile()) { return false; }//from w ww . j ava 2s. c om InputStream in = null; FileOutputStream fos = null; try { int len; in = new FileInputStream(oldFile); fos = new FileOutputStream(newPath); byte[] buffer = new byte[1024]; while ((len = in.read(buffer)) != -1) { fos.write(buffer, 0, len); } } catch (Exception e) { e.printStackTrace(); return false; } finally { try { if (in != null) in.close(); } catch (IOException e) { e.printStackTrace(); } try { if (fos != null) fos.close(); } catch (IOException e) { e.printStackTrace(); } } return true; } }