Java examples for File Path IO:Path
Path class implements the Iterable interface, you can obtain an object that enables you to iterate over the elements in the path.
import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path path = Paths.get("C:", "folder1/folder2/folder4", "test.txt"); for (Path name : path) { System.out.println(name); }/*from w w w .j a v a 2 s.co m*/ } }