Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How would I implement a login/register program in Java using a text file? Program will read from the text file to see if user exists

How would I implement a login/register program in Java using a text file? Program will read from the text file to see if user exists and can successfully login, if not, it will add a user to the text file.

image text in transcribed

Text file i'm trying to use:

image text in transcribed

public static boolean Login (User user, String username, String password) { private void createUserList File file = new File("UserList.txt"); FileReader fr; try { fr = new FileReader (file); BufferedReader br = new BufferedReader (fr); String line; User user = null; Password pass; while ((line = br.readLine()) != null) { String[] split line.split("\\s*,\\s*"); String tempUser split[0]; String temp Pass = split[i]; boolean login = false; if (user.equals((splitroll login = true; break; } } } catch (FileNotFoundException ex) { Logger.getLogger (Login.class.getName()).log(Level. SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Login.class.getName()).log(Level. SEVERE, null, ex); } return false; } UserList - Notepad File Edit Format View Help e User123, Password123 -. s Test13, Pass321 it Testing123, password it Username212, password1| it

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago