Leave a Reply 2

Your email address will not be published. Required fields are marked *


leo yu

leo yu

C)
path1.relativize(path2) means the route from path1 to path2

http://www.java2s.com/Tutorials/Java/java.nio.file/Path/Java_Path_relativize_Path_other_.htm

import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {

public static void main(String[] args) {

Path path01 = Paths.get(“Topic.txt”);
Path path02 = Paths.get(“Demo.txt”);
Path path03 = Paths.get(“/Java/JavaFX/Topic.txt”);
Path path04 = Paths.get(“/Java/2011”);

Path path01_to_path02 = path01.relativize(path02);
System.out.println(path01_to_path02);

Path path02_to_path01 = path02.relativize(path01);
System.out.println(path02_to_path01);

Path path03_to_path04 = path03.relativize(path04);
System.out.println(path03_to_path04);

Path path04_to_path03 = path04.relativize(path03);
System.out.println(path04_to_path03);
}

}

output:
../Demo.txt
../Topic.txt
../../2011
../JavaFX/Topic.txt

nmm

nmm

path = path.relativize….