| 6 | |
| 7 | public class PartsOfPaths { |
| 8 | public static void main(String[] args) { |
| 9 | System.out.println(System.getProperty("os.name")); |
| 10 | Path p = |
| 11 | Paths.get("PartsOfPaths.java").toAbsolutePath(); |
| 12 | for(int i = 0; i < p.getNameCount(); i++) |
| 13 | System.out.println(p.getName(i)); |
| 14 | System.out.println("ends with '.java': " + |
| 15 | p.endsWith(".java")); |
| 16 | for(Path pp : p) { |
| 17 | System.out.print(pp + ": "); |
| 18 | System.out.print(p.startsWith(pp) + " : "); |
| 19 | System.out.println(p.endsWith(pp)); |
| 20 | } |
| 21 | System.out.println("Starts with " + p.getRoot() + |
| 22 | " " + p.startsWith(p.getRoot())); |
| 23 | } |
| 24 | } |
| 25 | /* Output: |
| 26 | Windows 8.1 |