Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Login GUI and invalid attempts  RSS feed

 
Raziel Shabazz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do anyone have any ideas how I can complete my code for when a user login using their username/password it is compared to a text file with pre-listed name/password? If their name is not in the file it error out and the box closes.


 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to TellTheDetails.
What is the format of your data in the text file? "name=value" ? If yes, you can consider using the Properties class.

In pseudo code
1) When the application comes up, load the properties from the file
2) Accept user name + password from the user
3) Look up properties for a match
4) Process accordingly

I noticed you are using a null layout which is always a bad idea. You should be using a proper layout manager instead
 
Raziel Shabazz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The steps you listed is what I'm looking for. Do you have examples I can read. When the applications starts it do need to read my text file
 
Raziel Shabazz
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I crashed my code. I was getting the GUI dialog box now I get nothing. Any wise Guru's up to helping me out?

 
Jc Frane
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should use the following code for reading a text file:

FileInputStream fs = new FileInputStream("users.txt");
DataInputStream in = new DataInputStream(fs);
BufferedReader br = new BufferedReader(new InputStreamReader(in));

Note that it is also wise for you to use a Vector class or any Collection interface.
This will help you for reading your file easily especially when you are reading many records.

You should create a separate class for reading then there you create your Vector object and convert it to string or 2D array of string.
Then, do the searching with the string or the 2D array.

If you want to manipulate the file use String Builder.

Hope this will help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!