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.BufferedReader;

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

import java.util.ArrayList;

import java.util.List;

import android.content.Context;

public class Main {
    public static List<String> readFromFile(String file, Context context) {
        List<String> readLines = new ArrayList<String>();
        try {
            // File readFile = new File(config.getApp().getDir("files",
            // Context.MODE_WORLD_READABLE), file);

            BufferedReader reader = toReader(context.openFileInput(file));
            String read = null;
            while ((read = reader.readLine()) != null) {
                readLines.add(read);
            }
            reader.close();

        } catch (IOException e) {

        }
        return readLines;
    }

    public static BufferedReader toReader(InputStream is) {
        return new BufferedReader(new InputStreamReader(is), 8192);
    }
}