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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:59:55+00:00 2026-05-16T19:59:55+00:00

I need to retrieve the PIN from a notepad file (below) and check it

  • 0

I need to retrieve the PIN from a notepad file (below) and check it with the PIN which the user has typed. I have tried this for days, but so far the solution that I have come up with gives me the correct output only when I type the full row (i.e. 1598 01-10-102203-0 95000). Also it displays the “Invalid PIN” for each and every record.

PIN AccountNo   Balance
1598    01-10-102203-0  95000
4895    01-10-102248-0  45000
9512    01-10-102215-0  125000
6125    01-10-102248    85000

Output - You have login!

    Invalid PIN    
    Invalid PIN
    Invalid PIN
BufferedReader getIt = new BufferedReader(new InputStreamReader(System.in));
String userPIN = "";

try {
    // Open the file that is the first command line parameter
    FileInputStream fstream = new FileInputStream(
        "D:\\Studies\\BCAS\\HND\\Semester 1\\Programming "
        + "Concepts\\Assignment\\AccountInfo.txt");
    // Get the object of DataInputStream
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    //Read File Line By Line
    System.out.println("Enter PIN");
    userPIN = getIt.readLine();

    while ((strLine = br.readLine()) != null) {
        // Print the content on the console#    
        if (userPIN.equals(strLine)) {
            System.out.println("You have login!");
        } else {
            System.out.println("Invalid PIN!");
        }
    }
    //Close the input stream
    in.close();
} catch (Exception e) {//Catch exception if any
    System.err.println("Error: " + e.getMessage());
}
  • 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-16T19:59:56+00:00Added an answer on May 16, 2026 at 7:59 pm

    An essential element of Jon Freedman’s excellent answer, which you should consider accepting, is that you must break up the incoming line of text into its component parts in order to compare them to what is typed. Here’s one approach:

    String line = "1598 01-10-102203-0 95000";
    for (String s : line.split(" ")) {
        System.out.println(s);
    }
    

    This produces the following output:

    1598
    01-10-102203-0
    95000
    

    Addendum:

    while ((strLine = br.readLine()) != null) {
        String[] a = strLine.split(" ");
        // now the array a contains the three parts
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to retrieve a value from a website (can vary and I have
I need to retrieve information from two separate models which are similar but not
i need to retrieve the page title from an URL i already have using
I need to retrieve data (vehicle details, in this case) from a MySQL table
I need to retrieve ListingId from the below table based on the search condition.
I need to retrieve values from CakePHP's config file database.php from one of my
I need to retrieve from an Application Server (JBoss) a large file (gigabytes) and
I need to retrieve the element with specific class which is placed below in
I need to retrieve datas from the SQL Server 7.0 through java. I have
I need to retrieve columns which will be decided by user at run-time. Lets

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.