使用“。”创建路径。和“ ..”符号
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(); } }