I am creating a simple client-server architecture where the client connects to a server and the server client's user name Asks for and password. Usernames and passwords must be kept in a text file. If they are correct, then the client should be allowed to enter commands for the server.
What could be the best way to go about this, including the formatting of the text file, where the item should be drawn from?
Thank you.
You can use the BufferedReader or scanner to read the user name and password from the file To edit, you can use BufferedWriter.
BufferedReader br = new BufferedReader (new fileReader (new file ("C: \\ the \\ path \\ of_file.txt"))); String password = br.readLine ();
To edit it, you can use:
BufferedWriter bw = new BufferedWriter (new fileWriter (new file ("C: \\ File.path "))); Bw.write (new_password); Bw.close ();
All class packages are available in java.io
Comments
Post a Comment