首页 > 其他 > 详细

文件的复制

时间:2014-10-13 10:54:30      阅读:256      评论:0      收藏:0      [点我收藏+]
public static void doCopy(String PrimaryAddress, String NewAddress) {
		FileInputStream fis = null;
		FileOutputStream fos = null;
		try {
			fis = new FileInputStream(new File(PrimaryAddress));
			fos = new FileOutputStream(new File(NewAddress));
			byte [] buf = new byte[1024];
			int len = 0;
			while((len = fis.read(buf)) != -1) {
				fos.write(buf, 0, len);
				fos.flush();
			}
		} catch (Exception e) {
			System.err.println("文件复制失败!");
		}finally{
			try {
				if(fis != null) {
					fis.close();
				}
			} catch (Exception e2) {
				// TODO: handle exception
			}
			try {
				if(fos != null) {
					fos.close();
				}
			} catch (Exception e2) {
				// TODO: handle exception
			}
		}
	}

文件的复制

原文:http://blog.csdn.net/cs_12/article/details/40039307

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!