Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void updateCreds() {
- String userResponse;
- String username;
- boolean pass = false;
- boolean email = true;
- CSVReader reader = null;
- if (currentUsername != "") {
- try {
- reader = new CSVReader(new FileReader("bin/creds.csv"), ',');
- List<String[]> csvBody = reader.readAll();
- updater = new Scanner(System.in);
- while (true) {
- System.out.println("What would you like to update, Password or Email?");
- userResponse = updater.next();
- userResponse = toTitleCase(userResponse);
- if (userResponse.equals("Password")) {
- pass = true;
- break;
- } else if (userResponse.equals("Email")) {
- email = true;
- break;
- } else {
- System.out.println("Invalid Response");
- }
- }
- System.out.println("Current Username: " + currentUsername);
- for (String[] creds : csvBody) {
- if (currentUsername.equals(creds[1])) {
- if (pass) {
- System.out.println("Changing Password here");
- creds[2] = newPassword();
- } else if (email) {
- System.out.println("Changing Email here");
- creds[3] = newEmail();
- }
- }
- }
- CSVWriter writer = new CSVWriter(new FileWriter("bin/creds.csv"), ',', CSVWriter.NO_QUOTE_CHARACTER);
- writer.writeAll(csvBody);
- writer.flush();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- else{
- System.out.println("Verify you are logged in first!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement