国产探花免费观看_亚洲丰满少妇自慰呻吟_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();}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 固镇县| 隆化县| 汉阴县| 新干县| 贺州市| 山东省| 黄浦区| 宁阳县| 深水埗区| 财经| 长寿区| 涿州市| 隆回县| 寻甸| 嘉义市| 旬邑县| 海门市| 新密市| 贞丰县| 兴文县| 贺州市| 抚州市| 鄂伦春自治旗| 青州市| 龙海市| 斗六市| 美姑县| 浦城县| 榆林市| 杭锦后旗| 阿瓦提县| 渝北区| 陆良县| 建水县| 定边县| 卢氏县| 扎鲁特旗| 香港 | 红河县| 河南省| 山丹县|