码迷,mamicode.com
首页 > 编程语言 > 详细

Java实现文件复制

时间:2015-08-04 19:07:43      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
 * <p>CopyFile.java</p>
 * <p>Created on Apr 17, 2009, 4:33:43 PM</p>
 * <p>Copyright (c) 2007-2009. CUCKOO Workgroup, USTC, P.R.China</p>
 * @author Ren Jian
 */
public class CopyFile {
    private boolean copy(String fileFrom, String fileTo) {
        try {
            FileInputStream in = new java.io.FileInputStream(fileFrom);
            FileOutputStream out = new FileOutputStream(fileTo);
            byte[] bt = new byte[1024];
            int count;
            while ((count = in.read(bt)) > 0) {
                out.write(bt, 0, count);
            }
            in.close();
            out.close();
            return true;
        } catch (IOException ex) {
            return false;
        }
    }
}

 

Java实现文件复制

标签:

原文地址:http://www.cnblogs.com/toSeeMyDream/p/4702739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!