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

  • Home
  • SEARCH
  • 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 636487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:31:14+00:00 2026-05-13T20:31:14+00:00

I was wondering, If i had a java class, that wanted to consult a

  • 0

I was wondering, If i had a java class, that wanted to consult a txt file with say a list of names like

tom
steve
jones

how could i open the text file in the java program and basically see if a string contained in the program matches one of these names?

so far i have come up with

                try {
                BufferedReader inputReader = new BufferedReader(new FileReader("users.txt"));

                while (inputReader.readLine() != null){

                }

            } catch (FileNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (IOException ep) {
                // TODO Auto-generated catch block
                p.printStackTrace();
            }

but do not no where to go from here..

  • 1 1 Answer
  • 1 View
  • 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-13T20:31:15+00:00Added an answer on May 13, 2026 at 8:31 pm

    You need to store the result of readLine(), like:

    String nextLine;
    while ((nextLine = inputReader.readLine()) != null){
    if (nextLine.equals(stringToCheck)) {
        //do something
      }
    }
    

    (where stringToCheck is the target string, of course.)

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

Sidebar

Related Questions

I was wondering if scala had an equivalent to java's @SuppressWarnings that can be
I was wondering if Java had an equivalent to C#’s named pattern matching. For
I was wondering if anyone had any advice on parsing a file with fixed
I have a Java class that I'm debating what I should make it into
I was wondering if anyone had some resources that describe the binary protocol used
I recently ran across a class that had the following field declared: private final
just wondering when I had an iphone I was able to create a web
Just wondering if you had any thoughts on this problem. I want to make
Was wondering if anyone had any smart approaches to creating dynamic vanity user urls
I was wondering if anybody had any good sources for a game structure. I

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.