Here you can find the source of copyFile(File srcFile, File destFile)
public static void copyFile(File srcFile, File destFile) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.zip.CRC32; public class Main { private static final String JPEG = "jpeg"; private static final String JPG = "jpg"; private static final int BUFFER_SIZE = 4 * 1024; private static final boolean CLOCK = true; private static final boolean VERIFY = true; public static void copyFile(File srcFile, File destFile) throws IOException { if (!srcFile.getPath().toLowerCase().endsWith(JPG) && !srcFile.getPath().toLowerCase().endsWith(JPEG)) { return; }/*from ww w . jav a2 s. c om*/ final InputStream in = new FileInputStream(srcFile); final OutputStream out = new FileOutputStream(destFile); try { long millis = System.currentTimeMillis(); CRC32 checksum; if (VERIFY) { checksum = new CRC32(); checksum.reset(); } final byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = in.read(buffer); while (bytesRead >= 0) { if (VERIFY) { checksum.update(buffer, 0, bytesRead); } out.write(buffer, 0, bytesRead); bytesRead = in.read(buffer); } if (CLOCK) { millis = System.currentTimeMillis() - millis; } } catch (IOException e) { throw e; } finally { out.close(); in.close(); } } }