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

首頁 > 學院 > 開發設計 > 正文

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

2019-11-09 14:45:26
字體:
來源:轉載
供稿:網友

從assert文件下獲取文件名字

String[] fl1 = getAssets().list("第一層");得到數據  ["images", "hello.txt"]
String[] fl1 = getAssets().list("第一層/第二層");
得到數據  [ "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("存儲卡寫入失敗!");        }    }    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();}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 旌德县| 新绛县| 五家渠市| 彩票| 宜黄县| 醴陵市| 通榆县| 桃园县| 灌云县| 横山县| 文成县| 黑水县| 曲靖市| 青州市| 进贤县| 齐齐哈尔市| 镇沅| 北安市| 武城县| 丹东市| 永善县| 扎赉特旗| 礼泉县| 锡林郭勒盟| 方城县| 房山区| 阿城市| 台安县| 永吉县| 准格尔旗| 周宁县| 延长县| 永嘉县| 陵水| 志丹县| 固阳县| 临清市| 万源市| 翁源县| 杭锦后旗| 涿鹿县|