zoukankan      html  css  js  c++  java
  • Android 从资产目录Assert中复制东西的工具类

    package com.itheima.mobilesafe.utils;

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;

    import android.content.Context;

    public class AssetCopyUtils {  
             public static File copy(Context context, String fileName, String destPath) {
                      try {
                            InputStream is = context.getAssets().open(fileName);
                            File file = new File(destPath);
                            FileOutputStream fos = new FileOutputStream(file);
                            byte[] buffer = new byte[1024];
                            int len = 0;

                            while ((len = is.read(buffer)) != -1) {
                                  fos.write(buffer, 0, len);
                            }
                           fos.flush();
                           fos.close();
                           is.close();
                           return file;
                      } catch (Exception e) {
                          e.printStackTrace();
                          return null;
                      }

             }
    }

  • 相关阅读:
    快速搭建vue2.0开发环境
    node+websocket+react即时匿名通讯聊天室
    12月14日,Progress库
    12月9日,timer库
    12月7日,BOOST库安装及配置
    12月7日开始学习Boost
    is not allowed to connect to this MySQL server解决办法
    清华学堂练习题——传纸条
    makefile经典教程
    启动mysql服务命令
  • 原文地址:https://www.cnblogs.com/zhangping/p/3513833.html
Copyright © 2011-2022 走看看