Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static boolean copy(File source, File target) { if (source == null || target == null || !source.exists() || source.length() < 100) { return false; } try { FileOutputStream fos = new FileOutputStream(target); FileInputStream fis = new FileInputStream(source); int len = 0; byte[] buffer = new byte[1024]; while ((len = fis.read(buffer)) != -1) { fos.write(buffer, 0, len); } fos.flush(); fos.close(); fis.close(); return true; } catch (Exception e) { e.printStackTrace(); } return false; } }