首页 > 其他 > 详细

从assets中拷贝from文件到指定目录下

时间:2015-05-19 10:35:23      阅读:241      评论:0      收藏:0      [点我收藏+]
/**
	 * 
	 * 从assets中拷贝from文件到to目录下
	 * **/
	public void copyFile(Context context, String sourPath, String toPath) {

		OutputStream output = null;
		InputStream input = null;
		try {

			int read = 0;
			input = context.getResources().getAssets().open(sourPath);
			output = new BufferedOutputStream(new FileOutputStream(toPath));
			byte[] buf = new byte[2048];
			while ((read = input.read(buf)) != -1) {
				output.write(buf, 0, read);
			}

		} catch (Exception e) {
			Write.error(e.getMessage());
		} finally {
			try {
				if(output !=null){
					output.close();
				}
				if(input!=null){
				input.close();
				}
			} catch (IOException e) {
				Write.debug(""+e.getMessage());
			}
		}
	}

从assets中拷贝from文件到指定目录下

原文:http://blog.csdn.net/xiaoyi_tdcq/article/details/45840843

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