Advertisement
yerzhik

Untitled

Dec 3rd, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. private boolean changePasswordForAdmin(String pass) {
  2.         Properties props = new Properties();
  3.         InputStream is = Login.class.getResourceAsStream("/config.properties");
  4.         try {
  5.             props.load(is);
  6.             is.close();
  7.         } catch (IOException e) {
  8.             System.out.println("password change failed");
  9.             e.printStackTrace();
  10.             return false;
  11.         }
  12.  
  13.         FileOutputStream out;
  14.         try {
  15.             out = new FileOutputStream("/config.properties");
  16.             props.setProperty(passwordProperyKey, pass);
  17.             props.store(out, null);
  18.             out.close();
  19.             System.out.println("password changed");
  20.         } catch (FileNotFoundException e) {
  21.             e.printStackTrace();
  22.             System.out.println("password change failed");
  23.             return false;
  24.         } catch (IOException e) {
  25.             e.printStackTrace();
  26.             System.out.println("password change failed");
  27.             return false;
  28.         }
  29.        
  30.         return true;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement