public static byte[] assetAsByteArray(Resources res, String path) throws IOException {
        InputStream is = res.getAssets().open(path);

        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        byte[] temp = new byte[1024];
        int read;

        while ((read = is.read(temp)) > 0) {
            buf.write(temp, 0, read);
        }
        is.close();
        return buf.toByteArray();
    }
Loads an asset from a resource object and returns the content as {@code byte} array.

@param res  The resources from which the asset should be loaded.
@param path The path to the asset, as in {@link AssetManager#open}.
@return The content of the asset.
android/android_framework/base/src/main/java/util/XposedHelpers.java