Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.content.Context;
import android.content.res.AssetManager;

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

public class Main {
    /**
     * @param filePath example("text/text_1.txt")
     */
    public static InputStreamReader getAssetsText(Context context, String filePath) {
        InputStreamReader reader = null;
        AssetManager assetManager = context.getAssets();
        try {
            InputStream inputStream = assetManager.open(filePath);
            reader = new InputStreamReader(inputStream, "utf-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return reader;
    }
}