Here you can find the source of copyFile(String source, String destination)
public static void copyFile(String source, String destination) throws IOException
//package com.java2s; /*//from www .j a v a 2 s.c om * Copyright 2004 by EkoLiving Pty Ltd. All Rights Reserved. * * This software is the proprietary information of EkoLiving Pty Ltd. * Use is subject to license terms. */ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { private static final int BUFFER_SIZE = 16384; public static void copyFile(String source, String destination) throws IOException { BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream(source)); BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(destination)); int bytes; byte[] buffer = new byte[BUFFER_SIZE]; while ((bytes = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytes); } outputStream.flush(); outputStream.close(); inputStream.close(); } }