Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.BufferedReader;
import java.io.FileInputStream;

import java.io.IOException;

import java.io.InputStreamReader;

import android.content.Context;

public class Main {
    public static String getStringFromFile(final String filePath, final Context context) throws IOException {
        final FileInputStream in = context.openFileInput(filePath);
        final InputStreamReader inputStreamReader = new InputStreamReader(in);
        final BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        final StringBuilder sb = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            sb.append(line);
        }

        return sb.toString();
    }
}