@@ -0,0 +1,958 @@
+package week8;%0A%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.Scanner;%0A%0Apublic class WhileCheckPath %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%0A%09%09Scanner scanner = new Scanner(System.in);%0A%09%09Path path = null;%0A%09%09boolean isValid = false;%0A%09%09%0A%09%09while(isValid == false) %7B%0A%09%09%09// do stuff and try to get a valid path%0A%09%09%09// when the path is valid, it willl break loop%0A%09%09%09System.out.println(%22Please enter a path: %22);%0A%09%09%09String tempPath = scanner.nextLine();%0A%09%09%09%0A%09%09%09System.out.println(%22You typed: %22 + tempPath);%0A%09%09%09try %7B%0A%09%09%09%09path = Paths.get(tempPath);%0A%09%09%09%09System.out.println(%22Testing if this path exists: %22 + %0A%09%09%09%09%09%09path.toAbsolutePath());%0A%09%09%09%09%0A%09%09%09%09if(Files.exists(path)) %7B%0A%09%09%09%09%09isValid = true;%0A%09%09%09%09%09System.out.println(%22Awesome, it does exist%22);%0A%09%09%09%09%7D%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09System.out.println(e);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09// valid....%0A%09%09%0A%09%09System.out.println(%22Done, File path: %22 + path.toAbsolutePath());%0A%09%09%0A%09%7D%0A%0A%7D%0A

Create WhileCheckPath.java