RenderAndroid/WeexRenderExample/src/main/java/com/test/weex/render/activity/FileUtils.java
/**
     * Load file in asset directory.
     * @param path FilePath
     * @param context Weex Context
     * @return the Content of the file
     */
Load file in asset directory.
@param path FilePath
@param context Weex Context
@return the Content of the file
Load file in asset directory . @param path FilePath @param context Weex Context @return the Content of the file
public static String loadAsset(String path, Context context) {
        String content = fileCache.get(path);
        if(content != null){
            return content;
        }
        if (context == null || TextUtils.isEmpty(path)) {
            return null;
        }
        InputStream inputStream = null;
        try {
            inputStream = context.getAssets().open(path);
            content =  readStreamToString(inputStream);
            fileCache.put(path, content);
            return content;
        } catch (IOException e) {
            Log.e("Weex", "LOAD file" + path, e);
        }
        return "";
    }
public static String loadAsset ( String path , Context context ) { String content = fileCache . get ( path ) ; if ( content != null ) { return content ; } if ( context == null || TextUtils . isEmpty ( path ) ) { return null ; } InputStream inputStream = null ; try { inputStream = context . getAssets ( ) . open ( path ) ; content = readStreamToString ( inputStream ) ; fileCache . put ( path , content ) ; return content ; } catch ( IOException e ) { Log . e ( "Weex" , "LOAD file" + path , e ) ; } return "" ; }
Load file in asset directory.
Load file in asset directory .