Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static boolean fileCopy(File srcFile, File objFile) { if (srcFile == null || objFile == null) { return false; } boolean result; try { InputStream iStream = new FileInputStream(srcFile); OutputStream oStream = new FileOutputStream(objFile); streamCopy(iStream, oStream); iStream.close(); oStream.close(); result = true; } catch (IOException e) { e.printStackTrace(); result = false; } return result; } public static void streamCopy(InputStream is, OutputStream os) throws IOException { if (is == null || os == null) { return; } byte[] buffer = new byte[1024]; int len; while ((len = is.read(buffer)) > 0) { os.write(buffer, 0, len); } } }