集册 Java实例教程 使用“.”和“.”符号创建路径

使用“.”和“.”符号创建路径

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

200
使用“。”创建路径。和“ ..”符号

import java.net.URI;

import java.nio.file.FileSystems;

import java.nio.file.Path;//时 代      J a v a   公   众 号 - nowjava.com

import java.nio.file.Paths;


public class Main {


    public static void main(String[] args) {

        Path path16 = FileSystems.getDefault().getPath("/folder1/folder2/./folder4", "test.txt").normalize();

        Path path17 = Paths.get("C:/folder1/folder2/folder3/dummy/../test.txt").normalize();

        Path path18 = Paths.get("C:/folder1/folder2/./folder3/dummy/../test.txt").normalize();

    }

}