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 7822905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:04:05+00:00 2026-06-02T08:04:05+00:00

I am using a text file to read values from and loading this file

  • 0

I am using a text file to read values from and loading this file into a buffered reader. thereafter i am reading the file line by line and checking if any of line contains one of my keywords (i already have them in a list of String).

However, even though the line contains the keyword i am looking for it does not detects it and gives it a Miss. Here is the code

    for(int i=0;i<sortedKeywordList.size();i++)
        {
        String tempString=sortedKeywordList.get(i);
        while(US.readLine()!=null)
        {   
            String str=US.readLine();
            //System.out.println(str);
            if(str.contains(tempString)){
                System.out.println("Contains: "+tempString);
            }               
            else{
                System.out.println("Miss");
            }
        }
    }
  • 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-06-02T08:04:07+00:00Added an answer on June 2, 2026 at 8:04 am

    For each keyword, you’re iterating through your buffer using readLine(). So after your first keyword, you’ll have exhausted your buffer reading and the next keyword test won’t even execute since US.readLine() is giving you null. You’re not re-initialising your reader.

    So why not iterate through your file once (using your readLine() structure), and then for each line iterate through your keywords ?

    EDIT: As Hunter as pointed out (above) you’re also calling readLine() twice per loop. Once in your loop test and once to check each line for a keyword. I would first of all ensure you’re reading the file correctly (simply by printing out each line as you read it)

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

Sidebar

Related Questions

I am trying to read values from a text file using the Qt code
I'm using scanner to read a text file line by line but then how
I am trying to read some info from a text file by using windows
This loads a set of values from an XML file and places them into
I am attempting to read hex values from a text file. There can be
I'm trying to read the contents of a small text file using the common
I am using C# to read a ~120 MB plain-text CSV file. Initially I
I have to write a biginteger into a text file using the following statement.
I've been tasked with decrypting a text file using frequency analysis. This isn't a
i have been using an actionListener to pass text from numerous TextFields into a

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.