集册 Java实例教程 创建相对于根、C:/、D:/等的路径

创建相对于根、C:/、D:/等的路径

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

458
创建相对于root,C:/,D:/等的路径

import java.net.URI;/** 来 自 时 代 J a v a 公 众 号 - N o w J a v  a . c o m**/

import java.nio.file.FileSystems;

import java.nio.file.Path;

import java.nio.file.Paths;


public class Main {


    public static void main(String[] args) {

        

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

        Path path02 = Paths.get("/folder1", "folder2/folder3/test.txt");        

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

        Path path04 = FileSystems.getDefault().getPath(
展开阅读全文