Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.InputStream;

import android.content.Context;

public class Main {

    public static String readFile(Context context, String file, String code) {
        int len = 0;
        byte[] buf = null;
        String grammar = "";
        try {
            InputStream in = context.getAssets().open(file);
            len = in.available();
            buf = new byte[len];
            in.read(buf, 0, len);

            grammar = new String(buf, code);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return grammar;
    }
}