Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import android.content.res.AssetManager;
import java.io.InputStream;
import java.util.Hashtable;

public class Main {
    private static AssetManager sAssetManager;
    private static Hashtable mFileTable = new Hashtable();

    public static byte[] getAssetBytes(String path) {
        byte[] mBytes = null;
        if (sAssetManager != null) {
            InputStream input = null;
            try {
                input = sAssetManager.open(path);
                int length = input.available();
                mBytes = new byte[length];
                input.read(mBytes);
                input.close();
                if (!mFileTable.containsKey(path)) {
                    mFileTable.put(path, true);
                }
            } catch (Exception e) {
                if (!mFileTable.containsKey(path)) {
                    mFileTable.put(path, false);
                }
            }
        }
        return mBytes;
    }
}