• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  package com.android.tests.libstest.lib2;
2  
3  import android.app.Activity;
4  import android.widget.TextView;
5  
6  import java.io.BufferedReader;
7  import java.io.IOException;
8  import java.io.InputStream;
9  import java.io.InputStreamReader;
10  
11  public class Lib2 {
12  
handleTextView(Activity a)13      public static void handleTextView(Activity a) {
14          TextView tv = (TextView) a.findViewById(R.id.lib2_text2);
15          if (tv != null) {
16              tv.setText(getContent());
17          }
18      }
19  
getContent()20      private static String getContent() {
21          InputStream input = Lib2.class.getResourceAsStream("Lib2.txt");
22          if (input == null) {
23              return "FAILED TO FIND Lib2.txt";
24          }
25  
26          BufferedReader reader = null;
27          try {
28              reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
29  
30              return reader.readLine();
31          } catch (IOException e) {
32          } finally {
33              if (reader != null) {
34                  try {
35                      reader.close();
36                  } catch (IOException e) {
37                  }
38              }
39          }
40  
41          return "FAILED TO READ CONTENT";
42      }
43  }
44