Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. String username =jTextField1.getText();
  2.  
  3. String name=jTextField3.getText();
  4.  
  5. String address=jTextField2.getText();
  6. int phone=Integer.parseInt(jTextField5.getText());
  7.  
  8. String password=new String(jPasswordField1.getPassword());
  9. String lastname=jTextField4.getText();
  10.  
  11. int flag=0;
  12. try{
  13. if(username.equalsIgnoreCase("") || password.equalsIgnoreCase("") || address.equalsIgnoreCase("") || name.equalsIgnoreCase("") || lastname.equalsIgnoreCase("") )
  14. { JOptionPane.showMessageDialog(null,"The registration was not completed successfully");
  15. }
  16. }
  17. catch(NullPointerException ex1){
  18. }
  19. if(listofusers.LoggedInUser(username) ==1)
  20. {
  21. JOptionPane.showMessageDialog(null,"The registration was not completed successfully");
  22.  
  23. System.out.print("fafa");
  24. }
  25. else
  26. { listofusers.getArrayListOfUsers().add(new User(username,password,address,name,lastname,phone));
  27. JOptionPane.showMessageDialog(null,"The registration was completed successfully");
  28. counter++; }
  29. try {
  30. FileOutputStream out2 = new FileOutputStream("users.txt");
  31. PrintStream ps=new PrintStream(out2);
  32.  
  33. for (int j=0;j<listofusers.getArrayListOfUsers().size();j++)
  34.  
  35. {
  36. ps.append(listofusers.getArrayListOfUsers().get(j).getUsername()+"\t"+listofusers.getArrayListOfUsers().get(j).getPassword()+"\t"+
  37. "\t"+listofusers.getArrayListOfUsers().get(j).getAddress()+"\t"+listofusers.getArrayListOfUsers().get(j).getName()+"\t"+listofusers.getArrayListOfUsers().get(j).getLastname()+"\n"+"\n");
  38.  
  39. }
  40. out2.close();
  41. } catch (FileNotFoundException ex) {
  42. System.out.println(ex);
  43. } catch (IOException ex) {
  44. System.out.println(ex);
  45. }
  46. catch (Exception e) {
  47. System.err.println ("Error writing to file");
  48. }
  49.  
  50.  
  51. for(int i=0;i<listofusers.getArrayListOfUsers().size();i++)
  52. {
  53. System.out.println(listofusers.getArrayListOfUsers().get(i).getUsername()
  54. +listofusers.getArrayListOfUsers().get(i).getPassword()+listofusers.getArrayListOfUsers().get(i).getName());
  55. }
  56. object.setVisible(true);
  57. dispose();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement