Here you can find the source of copyFile(final File in, final File out)
Parameter | Description |
---|---|
in | src file |
out | dest file |
Parameter | Description |
---|---|
FileNotFoundException | an exception |
protected static void copyFile(final File in, final File out) 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; public class Main { /** Buffer size.*/ protected static final int BUFSIZE = 1024; /**/*from w ww . j a v a2 s.c o m*/ * Copy a file * @param in src file * @param out dest file * @throws FileNotFoundException */ protected static void copyFile(final File in, final File out) throws IOException { FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out); byte[] buf = new byte[BUFSIZE]; int i = 0; try { while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); } fis.close(); fos.close(); } catch (IOException e) { e.printStackTrace(); } } }