参数:filename (必须完整名字) public static String getAssetsCacheFile(Context context, String fileName) { Context mContext = App.getApplication(); File cacheFile = new File(mContext.getCacheDir(), fileName); try { InputStream inputStream = mContext.getAssets().open(fileName); try { FileOutputStream outputStream = new FileOutputStream(cacheFile); try { byte[] buf = new byte[1024]; int len; while ((len = inputStream.read(buf)) > 0) { outputStream.write(buf, 0, len); } } finally { outputStream.close(); } } finally { inputStream.close(); } } catch (IOException e) { e.printStackTrace(); } return cacheFile.getAbsolutePath(); }
Android 获取 assets文件夹文件地址
最新推荐文章于 2022-06-22 17:05:06 发布