Here you can find the source of fileCopy(String from, String to)
file copy
Parameter | Description |
---|---|
from | - from file |
to | - to file |
public static void fileCopy(String from, String to) throws IOException
//package com.java2s; //License from project: Apache License import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { /**//from www . j a v a 2 s . c o m * <p> * file copy * <p/> * * @param from * - from file * @param to * - to file * */ public static void fileCopy(String from, String to) throws IOException { FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(from); fos = new FileOutputStream(to); final int BUFSIZ = 1024; byte buf[] = new byte[BUFSIZ]; int len = 0; while ((len = fis.read(buf)) > 0) fos.write(buf, 0, len); } catch (Exception e) { // log.error("FileUtil, fileCopy, Exception error.", e); } finally { if (fis != null) fis.close(); if (fos != null) fos.close(); } } }