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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:40:11+00:00 2026-06-02T01:40:11+00:00

I am trying to make a login screen that can read the usernames and

  • 0

I am trying to make a login screen that can read the usernames and passwords from a text file. I have already built the registration page which outputs the username and password to a file by executing the following:

try (BufferedWriter out = new BufferedWriter(fstream)) {
            try {
              out.write(username + " " + password);
              out.newLine();
              JOptionPane.showMessageDialog(null,"User Account '" + username + "'     Created");
            } catch (IOException ex) {
                Logger.getLogger(ServerMenu.class.getName()).log(Level.SEVERE, null, ex);
            }
       }

the text file will looking something like this:

user1 password1
user2 password2

I have been reading through a lot of documentation to try and figure this one out however the more reading i do the more confused I get. The reason why I am doing it in this way is so that I can continue reading and writing to .dat files for the information that the system will eventually hold.

If anybody can help me in any way shape of form that would be amazing!

Thanks

C

  • 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-02T01:40:13+00:00Added an answer on June 2, 2026 at 1:40 am

    Quick and easy solution. Each line is commented but if you need any help or if there’s anything you don’t get please let know.

    import java.io.*;
    class FileRead 
    {
     public static boolean main(String lineToCompare)
      {
      try{
      // Open the file that is the first 
      // command line parameter
      FileInputStream fstream = new FileInputStream("textfile.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
    
      while ((strLine = br.readLine()) != null)   {
      //Compare the line with the line to compare (string)
      if(strLine.compareTo(lineToCompare) == 0)
          return true;
      }
    
      //Close the input stream
      in.close();
        }catch (Exception e){//Catch exception if any
         System.err.println("Error: " + e.getMessage());
      }
    
      return false;
    
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a forum. I already have the login and registration
I have been trying to make a secure login for my site that I
I have been trying to make a user login page that, when the user
I'm trying to make a login screen for Blackberry with input fields for username
I'm trying to make a simple login script that will check the inputted username
i'm a beginner in PHP and i'm trying to make a login screen using
I am trying to make a simple ball animation, that starts from 1 corner
I'm trying to make a splash screen for my Android app, where the login
I'm trying to make a login page using html, ajax & ASP.NET.The data is
I'm trying to make an auto login script and I'm stuck on the submit

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.