Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class Main {
    public static Context context;

    public static String readText(String fileName) {

        StringBuilder sb = new StringBuilder();

        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(context.getAssets().open(fileName)));

            String mLine = null;
            mLine = reader.readLine();
            while (mLine != null) {
                sb.append(mLine);
                sb.append("\n");
                mLine = reader.readLine();
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sb.toString();

    }
}