原文:http://mobile.51cto.com/aprogram-387591.htm

/**     * 存资源在data中     * @param ctxDealFile applicationContext     * @param path     */    public void deepFile(Context ctxDealFile, String path) {         try {             String str[] = ctxDealFile.getAssets().list(path);             if (str.length > 0) {//如果是目录                 File file = new File(ctxDealFile.getFilesDir().getAbsolutePath()+"/" + path);                 if (file.exists()) {                }else {                    file.mkdirs();                     for (String string : str) {                         path = path + "/" + string;                         deepFile(ctxDealFile, path);                         path = path.substring(0, path.lastIndexOf('/'));                     }                 }            } else {//如果是文件                 InputStream is = ctxDealFile.getAssets().open(path);                 FileOutputStream fos = new FileOutputStream(new File(ctxDealFile.getFilesDir().getAbsolutePath()+"/"                          + path));                 byte[] buffer = new byte[1024];                 int count = 0;                 while (true) {                     count++;                     int len = is.read(buffer);                     if (len == -1) {                         break;                     }                     fos.write(buffer, 0, len);                 }                 is.close();                 fos.close();             }         } catch (IOException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }     } 

更多相关文章

  1. android使用sharedPreferences()方法读写文件操作
  2. 在系统里设置文件默认打开APP
  3. Android实现屏幕截图并保存截图到指定文件
  4. Android 中读取SD卡文件时抛出NullPointerException错误解决办法
  5. Android media媒体库分析之:分类别统计媒体文件大小
  6. android文件处理
  7. Android复制Assets目录下的文件到指定目录

随机推荐

  1. Android 启动分析 init进程 init.rc
  2. Android程序版本控制工具类
  3. Android 毛玻璃效果的实现
  4. Android的界面设计工具——DroidDraw
  5. Android 数独游戏 记录
  6. Android中文API(132) —— GpsSatellite
  7. Android中文API(136) —— Bitmap
  8. Android ImageView 的scaleType属性
  9. android定时器(Timer,TimerTask)
  10. 安卓,rebuild apk错误解决