检查android资产文件夹html文件的存在

检查android资产文件夹html文件的存在,第1张

概述我将html文件传递为“file:///android_asset/WebApplication/index.html”.如何在android中检查此文件是否存在.解决方法:您可以尝试打开流,如果它失败,文件就不存在,如果它没有失败,文件应该在那里:/***Checkifanassetexists.Thiswillfailiftheassethasasize<1

我将HTML文件传递为“file:///android_asset/WebApplication/index.HTML”.如何在androID中检查此文件是否存在.

解决方法:

您可以尝试打开流,如果它失败,文件就不存在,如果它没有失败,文件应该在那里:

/** * Check if an asset exists. This will fail if the asset has a size < 1 byte. * @param context * @param path * @return TRUE if the asset exists and FALSE otherwise */public static boolean assetExists(Context context, String path) {    boolean bAssetok = false;    try {        inputStream stream = context.getAssets().open(ASSET_BASE_PATH + path);        stream.close();        bAssetok = true;    } catch (fileNotFoundException e) {        Log.w("IoUtilitIEs", "assetExists Failed: "+e.toString());    } catch (IOException e) {        Log.w("IoUtilitIEs", "assetExists Failed: "+e.toString());    }    return bAssetok;}
总结

以上是内存溢出为你收集整理的检查android资产文件夹html文件的存在全部内容,希望文章能够帮你解决检查android资产文件夹html文件的存在所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1106411.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存