国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 会东县| 太仆寺旗| 林口县| 化隆| 新丰县| 平邑县| 巴楚县| 灵丘县| 双桥区| 松江区| 新丰县| 株洲县| 婺源县| 阳朔县| 静宁县| 清徐县| 怀宁县| 岐山县| 龙游县| 顺义区| 保定市| 特克斯县| 岳阳市| 建平县| 台江县| 鄂托克旗| 连云港市| 尚义县| 通化县| 建德市| 乌拉特后旗| 洪江市| 客服| 中阳县| 九龙坡区| 鄢陵县| 宜君县| 玉环县| 军事| 淳化县| 固镇县|