集册 Java实例教程 在两个位置之间构建路径

在两个位置之间构建路径

欢马劈雪     最近更新时间:2020-01-02 10:19:05

424
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
在两个位置之间构建路径

import java.nio.file.Path;

import java.nio.file.Paths;
/** 来 自 n o w j a v a . c o m**/

public class Main {


    public static void main(String[] args) {


        Path path01 = Paths.get("test.txt");

        Path path02 = Paths.get("test2.txt");

        Path path03 = Paths.get("/folder2/folder3/test.txt");

        Path path04 = Paths.get("/folder2/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);

        /**
        来 自 时 代 J a v a - nowjava.com
        **/

        Path path03_to_path04 = path03.relativiz
展开阅读全文