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) {
//define the fix path
Path base_1 = Paths.get("C:/folder1/folder2/folder4");
Path base_2 = Paths.get("C:/folder1/folder2/folder3/test.txt");
//resolve test.txt file
Path path_1 = base_1.resolve("test.txt");
System.out.println(path_1.toString());
/**来 自 时代Java公众号**/
//resolve test2.txt file
Path path_2 = base_1.resolve("test2.txt");
System.out.println(path_2.toString());
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。