Prompt user for directory until user enters a correct file path
Reformatted the prompt concerning the directory specified by user. It continues asking the user for the correct file path if wrong is entered.
if (answer.contains("Y") || answer.contains("y") || answer.contains("yes") || answer.contains("Yes")) {
System.out.println("Great! Lets get started!\n");
directory = "C:\\Users\\Public\\Documents";
return directory;
} else {
boolean exists = false;
System.out.println("Please enter a new directory: ");
Scanner askNewDirectory = new Scanner(System.in);
while (exists != true) {
String newDirectory = askNewDirectory.next();
File tempDir = new File(newDirectory);
boolean exists2 = tempDir.exists();
if (exists2 == true) {
exists = true;
directory = newDirectory;
System.out.println("New directory set to: " + directory);
} else {
System.out.println("Wrong file path. Please try again.");
}
}
}