android - read from text file line by line
<p>I have the following code which I know that works in Java. I am now trying to do the equivalent in and Android application. The operation is quite simple: I need to make use of a method in a class (in the same workspace) where I first need to get the lines off a text file which I stored in <strong>/res/raw</strong>.</p>

<p>Basically I need to call this method residing in a Java class from an Android Activity Class. How is this possible?</p>

<p>Activity Class snippet (CaptureActivity.java):</p>

<pre><code>setContentView(R.layout.orientation);
                        try {
                            SentenceGenerator sentenceGenerator = new SentenceGenerator();
                            ArrayList&lt;String&gt; firstState = stateGenerator.getState(resultOutput, result, result);
                            String viewPoint = firstState.get(0);
                            String object = firstState.get(1);
                            String subject = firstState.get(2);
                            Thing subjectInfo = new Thing();
                            if(resultOutput.equals("Sliema")){
                                Sliema sliema = new Sliema();
                                subjectInfo = sliema.getInfo(viewPoint, object, subject);
                            }
                            try {
                                String s = sentenceGenerator.generateSentence("start.txt", "middle.txt", "end.txt", resultOutput, viewPoint, object, subject, subjectInfo.type, subjectInfo.name, subjectInfo.properties, false);
                                TextView instructionTextView = (TextView) findViewById(R.id.instructionTextView);
                                instructionTextView.setText(s);

                            } catch (Exception e) {
                            }
                        } catch (ClassNotFoundException e) {
                        }
</code></pre>

<p>Java Class snippet (SentenceGenerator.java):</p>

<pre><code>public static ArrayList&lt;String&gt; getLines(String filename) throws Exception {
    ArrayList&lt;String&gt; lines = new ArrayList&lt;String&gt;();
    FileInputStream fstream = new FileInputStream(filename);
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    while ((strLine = br.readLine()) != null) {
        lines.add(strLine);
    }
    in.close();
    return lines;
}
</code></pre>

<p>Thank you for any help in advance!</p>
