Guest User

Untitled

a guest
May 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. JButton btnSubmit = new JButton("Submit");
  2. btnSubmit.addActionListener(new ActionListener() {
  3. public void actionPerformed(ActionEvent arg0) {
  4.  
  5. File EmployeeFile = new File("C:/Users/Nicol/Desktop/Employeesname.txt");
  6. if(!EmployeeFile.exists())
  7. {
  8. try
  9. {
  10. boolean HasBeenCreated = EmployeeFile.createNewFile();
  11. if(HasBeenCreated)
  12. {
  13. System.out.println("A new employee has been added succesfully! Their detail-file has been created on the desktop.");
  14. }
  15. else
  16. {
  17. System.out.println("An error occured. Employee's file has not been created.");
  18. }
  19. }
  20. catch (IOException ex)
  21. {
  22. ex.printStackTrace();
  23. }
  24.  
  25. }
Add Comment
Please, Sign In to add comment