Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

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

import android.content.Context;

import android.util.Log;

public class Main {
    /**
     * Get file content by filename
     * 
     * @param c
     * @param filename
     * @return content String
     */
    public static String getFileContent(Context c, String filename) {
        try {
            InputStream fin = c.getAssets().open(filename);
            byte[] buffer = new byte[fin.available()];
            fin.read(buffer);
            fin.close();
            return new String(buffer);
        } catch (IOException e) {
            Log.e("inspector", e.getLocalizedMessage());
        }
        return "";
    }
}