public class CLIENT_PATH { String PATH; Path Path; public void INPUT_PATH(){ out.println("Введите путь"); do { out.print(" "); Scanner in = new Scanner(System.in); PATH = in.next(); Path = Paths.get(PATH); if (Files.exists(Path)) { out.println(" Путь введён\n"); } else out.println(" Ошибка"); } while(Files.notExists(Path)); out.println(PATH); } } When entering the Russian characters K (R), P (G), O (J), and M (V) as well as the characters ", No. and possibly others throw an exception. I want to emphasize that when entering characters # or $ and others, the exception does not throw How to handle exceptions?
Enter the path
P
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <? > at index 0:?
Enter the path
m
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <<> at index 0: <

/ \ : * ? " < > |/ \ : * ? " < > |prohibited byWindowsitself. Now I tried it: Russian paths are not recognized either, but there are no errors. I am sure this problem is solved. You can try using character codes:\u0000and so on. - Peter Samokhin