Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static boolean copyFile(String srcPath, String destPath) { return copyFile(new File(srcPath), new File(destPath)); } public static boolean copyFile(File src, File dest) { if (!src.exists()) return false; FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(src); fos = new FileOutputStream(dest); byte[] buffer = new byte[2048]; int bytesread = 0; while ((bytesread = fis.read(buffer)) != -1) { if (bytesread > 0) fos.write(buffer, 0, bytesread); } return true; } catch (FileNotFoundException e) { return false; } catch (IOException e) { return false; } finally { if (fis != null) { try { fis.close(); } catch (Exception e2) { } } if (fos != null) { try { fos.close(); } catch (Exception e2) { } } } } }