Here you can find the source of copyFile(File src, File dest)
Parameter | Description |
---|---|
src | java.io.File |
dest | java.io.File |
public static void copyFile(File src, File dest) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**//from w w w . j a va2 s . c om * Insert the method's description here. * Creation date: (30.01.01 09:22:29) * @param src java.io.File * @param dest java.io.File */ public static void copyFile(File src, File dest) throws IOException { InputStream ss = null; OutputStream ds = null; try { ss = new BufferedInputStream(new FileInputStream(src)); ds = new BufferedOutputStream(new FileOutputStream(dest)); copyStream(ss, ds); } finally { if (ds != null) { ds.close(); } if (ss != null) { ss.close(); } } } /** * Insert the method's description here. * Creation date: (30.01.01 09:22:29) * @param src java.io.File * @param dest java.io.File */ public static void copyStream(InputStream src, OutputStream dest) throws IOException { int c; while ((c = src.read()) != -1) { dest.write(c); } } }