import java.nio.file.Path;
import java.nio.file.Paths;
/** 时 代 Java - nowjava.com 提 供 **/
public class Main {
public static void main(String[] args) {
Path path = Paths.get("C:", "folder1/folder2/folder4", "test.txt");
System.out.println("The file/directory indicated by path: " + path.getFileName());
System.out.println("Root of this path: " + path.getRoot());
System.out.println("Parent: " + path.getParent());
System.out.println("Number of name elements is path: " + path.getNameCount());
for (int i = 0; i < path.getNameCount(); i++) {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。