国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

獲取assert目錄下文件名及讀取

2019-11-09 13:56:19
字體:
供稿:網(wǎng)友

從assert文件下獲取文件名字

String[] fl1 = getAssets().list("第一層");得到數(shù)據(jù)  ["images", "hello.txt"]
String[] fl1 = getAssets().list("第一層/第二層");
得到數(shù)據(jù)  [ "helloworld.txt"]將assert文件copy到sd卡
/** * * @param fileName   "第一層/第二層/helloworld.txt" * @param desDir  "/mnt/sdcard/mypath/" * @throws Exception */PRivate void CopyAssetFile(String fileName, String desDir) throws Exception {    String strCPSDPath = desDir + fileName;//  "/mnt/sdcard/mypath/第一層/第二層/helloworld.txt"    File file = new File(strCpSdPath);        if (!file.getParentFile().exists()) {        if (!file.getParentFile().mkdirs()) {            Log.i("--CopyAssets--", "cannot create directory.");            throw new Exception("存儲(chǔ)卡寫入失敗!");        }    }    InputStream myInput = getAssets().open(fileName);    file.createNewFile();    OutputStream myOutput = new FileOutputStream(file, true);    byte[] buffer = new byte[1024];    int length;    while ((length = myInput.read(buffer)) > 0) {        myOutput.write(buffer, 0, length);    }    myOutput.flush();    myOutput.close();    myInput.close();}


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 唐河县| 肇庆市| 桐柏县| 游戏| 茂名市| 遵义县| 拉孜县| 虞城县| 仙桃市| 灌云县| 石渠县| 海宁市| 罗甸县| 苏尼特左旗| 西贡区| 新蔡县| 咸宁市| 湖南省| 南皮县| 高邮市| 鲜城| 丁青县| 宁陕县| 广昌县| 兴安盟| 剑川县| 恩平市| 出国| 天气| 临高县| 林周县| 利辛县| 南通市| 沛县| 陆良县| 二连浩特市| 湘乡市| 绥阳县| 白河县| 万州区| 资溪县|