Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. public boolean isCustomer(){
  2. boolean isFound = false;
  3. String record = null;
  4. FileReader in = null;
  5. try{
  6. in = new FileReader ("login.txt");
  7. BufferedReader bin = new BufferedReader(in);
  8. record = new String();
  9. while ((record = bin.readLine()) != null)
  10. {
  11. if (NameTextField.getText().contentEquals(record))
  12. isFound = true;
  13. if (jPasswordField.getText().contentEquals(record))
  14. isFound = true;
  15. }
  16.  
  17. bin.close();
  18. bin = null;
  19. }catch(IOException ioe){
  20. NameTextField.setText("IOProblem");
  21. }
  22. return isFound;
  23.  
  24. Joe
  25.  
  26. 656451asda
  27.  
  28. $$$
  29.  
  30. Robert
  31.  
  32. 123456hbb
  33.  
  34. $$$
  35.  
  36. Tracey
  37.  
  38. 56464999abc
  39.  
  40. $$$
  41.  
  42. Celia
  43.  
  44. abc1234897
  45.  
  46. $$$
  47.  
  48. private String getUsername(String filename) {
  49. // 1. Open up the file.
  50. // 2. Return the String.
  51. }
  52.  
  53. private String getPassword(String filename) {
  54. // Basically the same, but return the password.
  55. }
  56.  
  57. String username = getUsername(filename);
  58. String password = getPassword(filename);
  59. return (username != null) && (password != null); // makes sure they're both there.
  60.  
  61. if (NameTextField.getText().contentEquals(record))
  62. isFound = true;
  63. if (jPasswordField.getText().contentEquals(record))
  64. isFound = true;
  65.  
  66. if (foundUser && jPasswordField.getText().contentEquals(record)) {
  67. foundPassword = true;
  68. break; // No need to compare any more details...
  69. } else {
  70. foundUser = false;
  71. }
  72. if (NameTextField.getText().contentEquals(record)) {
  73. foundUser = true;
  74. }
  75.  
  76. joe:fjckdsoij48738423
  77. marian:fjccoekrnvn3iernci3en
  78. mrbean:fjd84jfn4u48fu4nf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement