Could it be that line.containes() is missing a search-term in Android?
<p>Something strange happens on a text parser that I am writing an I thought maybe you experts can find what I am doing wrong.</p>

<p>The parser  is searching for several search-terms in the text and copy the found results to an output parsed file on the SD card.</p>

<p>The code is:</p>

<pre><code>String line; // line reading buffer
…

Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0]));

         BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

…

while ((line = bufferedReader.readLine()) != null){

            line = bufferedReader.readLine(); // reading the buffer

          /*** parsing the buffer line by line   ***/


                if (line.contains("SearchTermA")){  
                    // parsing the text in this line
                }

                if (line.contains("SearchTermB")){
                    // parsing the text in this line
                }


                // Check that we got to a cretin part in the file
                if (line.contains("SearchTerm_text")){
                     textID = 1;    
                }

                if (textID == 1){
                  if (line.contains("SearchTermC")){
                       // parsing the text in this line
                                                     }
                }
</code></pre>

<p>Now, the issue is that at the beginning of the file (the file is very long) this works OK but sometimes along the way SearchTermB appears in the original text but is not deceted by the code. I tried stepping the code with Eclipse on the target android machin and I can clearly see that “line” contains SerchTermB but the debugger ignores this IF statement and continue to the next IF statement.</p>

<p>Could it be that line.containes() is missing a search-term? </p>

<p>Please help in finding what am I doing wrong since this prevents me from sleeping at night…..</p>

<p>Thanks,</p>
