通过URI定义路径
import java.net.URI; 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 path = Paths.get(URI .create("file:///folder1/folder2/folder3/test.txt")); path = Paths.get(URI .create("file:///C:/folder1/folder2/folder3/test.txt")); } }