Results 1 to 2 of 2
Thread: Problem when reading files
- 03-20-2012, 11:04 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 1
- Rep Power
- 0
Problem when reading files
Hi all!
Im new in programming and I'm having a problem with a work I have to do, and I really need someone to tell me what I'm doing wrong.
To sum up, what I have to do is to simulate a login system, so I created a class which has that funcionality, the 'login' method.
By reading a file with Buffered reader, I have to enter with keyboard a code and a password, and then It has to check if they match (there are 2 codes and 2 passwords, each code associated to a password)
The file is something like this (not this actually)
code1:
9872
password:
perfsf
code2:
0078
password:
uuylk
Taking in count that I cant change anything in the file, how could I do it?
What ive done is, by using 4 variables (passw, code, passwfile, codefile, 2 of them are filled by keyboard) I'd like to compare passw and code with passwfile and codefile, which are filled by reading the file.
Well, the problem is that I dont know how to assign to passwfile and to codefile the right line of the file in order to compare them with passw and code.
Any help?
(Sorry for my bad english, it's not my native language)
Thank you.
If you need part of my code I'll post it.
-
Re: Problem when reading files
You will need to take input from the User, which you could do with the Scanner class. You then need to read a text file and check if what the user entered matches any password/username combination - You can also do that with the Scanner class.
You can read more about it here:
Scanner (Java 2 Platform SE 5.0)
Scanning (The Java™ Tutorials > Essential Classes > Basic I/O)
Similar Threads
-
Reading files
By ptuckley in forum New To JavaReplies: 7Last Post: 08-16-2011, 02:18 AM -
problem reading a files lines
By j187 in forum New To JavaReplies: 1Last Post: 12-17-2010, 12:43 AM -
Bug Reading txt files
By MHardeman25 in forum New To JavaReplies: 4Last Post: 08-13-2010, 10:03 PM -
Reading .bin files
By spatel14 in forum New To JavaReplies: 3Last Post: 06-22-2010, 04:39 PM -
problem with reading excel sheet data reading using poi libraries
By sandeepsai17 in forum New To JavaReplies: 5Last Post: 08-21-2009, 11:03 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks