import java.nio.file.Path;
import java.nio.file.Paths;
public class Main {//from 时 代 Java 公 众 号 - nowjava.com
public static void main(String[] args) {
Path firstPath;
Path secondPath;
firstPath = Paths.get("music/Future Setting A.mp3");
secondPath = Paths.get("docs");
System.out.println("From firstPath to secondPath: "
+ firstPath.relativize(secondPath));
System.out.println("From secondPath to firstPath: "
+ secondPath.relativize(firstPath));
System.out.println();
firstPath = Paths.get("music/Future Setting A.mp3");
secondPath = Paths.get("music");
System.out.println("From firstPath to secondPath: "
+ firstPath.relativize(secondPath));
System.out.println("From secondPath to firstPath: "
+ secondPath.relativize(firstPath));
System.out.println();//NowJava.com 提供
firstPath = Paths.get("music/Future Setting A.mp3");
secondPath = Paths.get("docs/users.txt");
System.out.println("From firstPath to secondPath: "
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。