assets目录下资源拷贝到指定目录
来源:互联网 发布:研究生论文数据造假 编辑:程序博客网 时间:2024/06/05 20:21
/** * 从assets目录中复制整个文件夹内容 * @param context Context 使用CopyFiles类的Activity * @param oldPath String 原文件路径 如:/aa * @param newPath String 复制后路径 如:xx:/bb/cc */ public void copyFilesFassets(Context context,String oldPath,String newPath) { try { String fileNames[] = context.getAssets().list(oldPath);//获取assets目录下的所有文件及目录名 if (fileNames.length > 0) {//如果是目录 File file = new File(newPath); file.mkdirs();//如果文件夹不存在,则递归 for (String fileName : fileNames) { copyFilesFassets(context,oldPath + "/" + fileName,newPath+"/"+fileName); } } else {//如果是文件 InputStream is = context.getAssets().open(oldPath); FileOutputStream fos = new FileOutputStream(new File(newPath)); byte[] buffer = new byte[1024]; int byteCount=0; while((byteCount=is.read(buffer))!=-1) {//循环从输入流读取 buffer字节 fos.write(buffer, 0, byteCount);//将读取的输入流写入到输出流 } fos.flush();//刷新缓冲区 is.close(); fos.close(); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); //如果捕捉到错误则通知UI线程 MainActivity.handler.sendEmptyMessage(COPY_FALSE); } }
阅读全文
0 0
- assets目录下资源拷贝到指定目录
- Android递归拷贝assets资源到指定目录
- 从assets中拷贝from文件到指定目录下
- Android 读取Assets资源文件或目录,并拷贝到其他目录下
- Android从Assets拷贝文件以及文件夹到指定目录
- Android 拷贝assets目录下所有文件及文件夹到指定路径
- Android复制Assets目录下的文件到指定目录
- cocos 拷贝Lua资源到android 工程assets目录
- assets目录下所有文件拷贝到sd卡
- assets目录下资源使用方法
- 读取assets目录下的资源文件写入到本地
- 从assets拷贝数据库到file目录
- assets目录下的文件拷贝到sd卡目录下
- 拷贝文件到指定目录
- 拷贝文件到指定目录
- android:将assets目录下的文件(文件夹)放置到内存卡指定目录下
- android拷贝assets目录下文件到其他目录
- android应用Assets目录下的资源
- 【算法】使用大根堆,解决top_k问题
- LeetCode---Judge Route Circle
- 那些年,今天
- 如何将3d文件在网页中显示(webGL,three.js)
- webservice如何生成客户端
- assets目录下资源拷贝到指定目录
- 欢迎使用CSDN-markdown编辑器
- 以太坊的Ethash算法
- MySQL常用命令
- [Javascript 高级程序设计]学习心得记录3 根据对象数组的属性进行排序
- 排序算法
- PHP7.1.8 cURL开启失败问题解决办法
- ECharts-gl中三维图片旋转问题
- 三连游戏优化--α-β裁剪