Here you can find the source of copyFile(String f1, String f2)
Parameter | Description |
---|---|
f1 | a parameter |
f2 | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static void copyFile(String f1, String f2) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { /**/*from w w w.ja v a 2 s .c o m*/ * copy f1 to f2 * @param f1 * @param f2 * @throws Exception */ public static void copyFile(String f1, String f2) throws Exception { FileInputStream is = new FileInputStream(f1); FileOutputStream f = new FileOutputStream(f2); byte[] b = new byte[1024]; int m = is.read(b); while (m != -1) { f.write(b, 0, m); m = is.read(b); } f.close(); } }