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.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.content.res.Resources;
import android.util.Log;

public class Main {
    private static final String TAG = "VoUtil";

    public static List<String> fileReader(Context context, int rawId) {
        Resources myRes = context.getResources();
        String data = null;
        List<String> list = new ArrayList<String>();

        BufferedReader br = null;
        try {
            br = new BufferedReader(new InputStreamReader(myRes.openRawResource(rawId)));

            do {
                data = br.readLine();
                if (data == null) {
                    break;
                }
                list.add(data);
                //Log.i(TAG, data);
            } while (true);

        } catch (Exception e) {
            e.printStackTrace();
            Log.e(TAG, e.getMessage());
        }

        return list;
    }
}