Java tutorial
//package com.java2s; /** * FSML utility methods. * * @author BaseX Team 2005-11, BSD License * @author Alexander Holupirek */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** * Copies source file to destination. * If destination file exists it will be overwritten silently. * * @param source file * @param target file */ public static void copyFile(final File source, final File target) { try { FileInputStream in = new FileInputStream(source); FileOutputStream out = new FileOutputStream(target); byte[] buf = new byte[4096]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); in.close(); } catch (IOException e) { e.printStackTrace(); } } }