Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

import android.content.Context;
import android.content.res.AssetManager;

public class Main {
    private static Context context;

    public static byte[] readFileFromAsset(String fileName) throws IOException {
        AssetManager assetMgr = context.getAssets();
        InputStream is = assetMgr.open(fileName);
        int size = is.available();
        byte[] content = new byte[size];
        is.read(content);
        is.close();
        return content;
    }
}