Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String username =jTextField1.getText();
- String name=jTextField3.getText();
- String address=jTextField2.getText();
- int phone=Integer.parseInt(jTextField5.getText());
- String password=new String(jPasswordField1.getPassword());
- String lastname=jTextField4.getText();
- int flag=0;
- try{
- if(username.equalsIgnoreCase("") || password.equalsIgnoreCase("") || address.equalsIgnoreCase("") || name.equalsIgnoreCase("") || lastname.equalsIgnoreCase("") )
- { JOptionPane.showMessageDialog(null,"The registration was not completed successfully");
- }
- }
- catch(NullPointerException ex1){
- }
- if(listofusers.LoggedInUser(username) ==1)
- {
- JOptionPane.showMessageDialog(null,"The registration was not completed successfully");
- System.out.print("fafa");
- }
- else
- { listofusers.getArrayListOfUsers().add(new User(username,password,address,name,lastname,phone));
- JOptionPane.showMessageDialog(null,"The registration was completed successfully");
- counter++; }
- try {
- FileOutputStream out2 = new FileOutputStream("users.txt");
- PrintStream ps=new PrintStream(out2);
- for (int j=0;j<listofusers.getArrayListOfUsers().size();j++)
- {
- ps.append(listofusers.getArrayListOfUsers().get(j).getUsername()+"\t"+listofusers.getArrayListOfUsers().get(j).getPassword()+"\t"+
- "\t"+listofusers.getArrayListOfUsers().get(j).getAddress()+"\t"+listofusers.getArrayListOfUsers().get(j).getName()+"\t"+listofusers.getArrayListOfUsers().get(j).getLastname()+"\n"+"\n");
- }
- out2.close();
- } catch (FileNotFoundException ex) {
- System.out.println(ex);
- } catch (IOException ex) {
- System.out.println(ex);
- }
- catch (Exception e) {
- System.err.println ("Error writing to file");
- }
- for(int i=0;i<listofusers.getArrayListOfUsers().size();i++)
- {
- System.out.println(listofusers.getArrayListOfUsers().get(i).getUsername()
- +listofusers.getArrayListOfUsers().get(i).getPassword()+listofusers.getArrayListOfUsers().get(i).getName());
- }
- object.setVisible(true);
- dispose();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement