Here you can find the source of resolvePathElements(final Path path)
static LinkedList<String> resolvePathElements(final Path path)
//package com.java2s; //License from project: Open Source License import java.nio.file.Path; import java.util.LinkedList; import java.util.regex.Pattern; import com.google.common.base.Strings; import com.google.common.collect.Lists; public class Main { static LinkedList<String> resolvePathElements(final Path path) { final LinkedList<String> elements = Lists.newLinkedList(); final String[] elementArray = path.toString().split(Pattern.quote(path.getFileSystem().getSeparator())); for (final String element : elementArray) { if (!Strings.isNullOrEmpty(element)) { elements.add(element);//from w w w. j a v a2 s.c o m } } return elements; } }