Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean isCustomer(){
- boolean isFound = false;
- String record = null;
- FileReader in = null;
- try{
- in = new FileReader ("login.txt");
- BufferedReader bin = new BufferedReader(in);
- record = new String();
- while ((record = bin.readLine()) != null)
- {
- if (NameTextField.getText().contentEquals(record))
- isFound = true;
- if (jPasswordField.getText().contentEquals(record))
- isFound = true;
- }
- bin.close();
- bin = null;
- }catch(IOException ioe){
- NameTextField.setText("IOProblem");
- }
- return isFound;
- Joe
- 656451asda
- $$$
- Robert
- 123456hbb
- $$$
- Tracey
- 56464999abc
- $$$
- Celia
- abc1234897
- $$$
- private String getUsername(String filename) {
- // 1. Open up the file.
- // 2. Return the String.
- }
- private String getPassword(String filename) {
- // Basically the same, but return the password.
- }
- String username = getUsername(filename);
- String password = getPassword(filename);
- return (username != null) && (password != null); // makes sure they're both there.
- if (NameTextField.getText().contentEquals(record))
- isFound = true;
- if (jPasswordField.getText().contentEquals(record))
- isFound = true;
- if (foundUser && jPasswordField.getText().contentEquals(record)) {
- foundPassword = true;
- break; // No need to compare any more details...
- } else {
- foundUser = false;
- }
- if (NameTextField.getText().contentEquals(record)) {
- foundUser = true;
- }
- joe:fjckdsoij48738423
- marian:fjccoekrnvn3iernci3en
- mrbean:fjd84jfn4u48fu4nf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement