aboutsummaryrefslogtreecommitdiff
path: root/testapps/libsTest/lib1/src/com/android/tests/libstest/lib1/Lib1.java
blob: c62bec228690db5360717d36e9e862e8d4e1d32f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.android.tests.libstest.lib1;

import android.app.Activity;
import android.widget.TextView;

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

public class Lib1 {
    
    public static void handleTextView(Activity a) {
        TextView tv = (TextView) a.findViewById(R.id.lib1_text2);
        if (tv != null) {
            tv.setText(Lib1.getContent());
        }
    }

    public static String getContent() {
        InputStream input = Lib1.class.getResourceAsStream("Lib1.txt");
        if (input == null) {
            return "FAILED TO FIND Lib1.txt";
        }

        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));

            return reader.readLine();
        } catch (IOException e) {
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                }
            }
        }
        
        return "FAILED TO READ CONTENT";
    }
}