Here is the message from the validator:
To calculate the relative path, the relativize() method of the Path class should be used.
Do not know what to do. Please advise
package en.codegym.task.pro.task15.task1514;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;
/*
It's all relative
*/
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String str1 = scanner.nextLine();
String str2 = scanner.nextLine();
// String str3 = "C:\\projects\\newCopy\\logNumber2.txt";
// String str4 = "C:\\projects";
Path path1 = Path.of(str1);
Path path2 = Path.of(str2);
Path relativePath1 = path2.relativize(path1);
Path relativePath2 = path1.relativize(path2);
if (path1.getRoot().toString().equals(path2.getRoot().toString())) {
if (relativePath2.toString().equals("..\\..")) {
System.out.println(relativePath1);
} else {
System.out.println(relativePath2);
}
}
}
}