Answered step by step
Verified Expert Solution
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.
Text file i'm trying to use:
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| itStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started