集册 Java实例教程 从URI定义路径

从URI定义路径

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

493
通过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"));

  }

}