Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7042907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:13:29+00:00 2026-05-28T02:13:29+00:00

Something strange happens on a text parser that I am writing an I thought

  • 0

Something strange happens on a text parser that I am writing an I thought maybe you experts can find what I am doing wrong.

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.

The code is:

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
                                                     }
                }

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.

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

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

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:13:29+00:00Added an answer on May 28, 2026 at 2:13 am

    Your while loop is reading two lines at a time…

    while ((line = bufferedReader.readLine()) != null){
    
        line = bufferedReader.readLine(); // reading the buffer
    

    In other words you call readLine() in your while statement in order to check that it’s not a null result and then you immediately call readLine() again.

    Get rid of this…

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

    …and see what happens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been doing spring cleaning in my app. I noticed something strange, that,
I come across several problems while trying django unittests library. Something strange happens: I
I'm experiencing something really strange! I have a div that I'm hiding with JS
I notice something strange happens to one of my view controller: the back button
I try to create a customized legend in my chart but something strange happens
I am having a strange problem with boolean logic. I must be doing something
Something strange happens. I have in my code in a local function #ifdef abc
i am trying to build an custom validator with symfony2 but something strange happens:
im trying to style my radiobutton. But something strange happens when i compile and
Something strange is happening in my code where I'm using a StackTrace. It's almost

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.