Danke !!!
Für alle Mitleser, hier sind die passende Befehle MIT Beispiele !
subpath ist das was ich brauche
Path path = Paths.get("/home/joe/foo");
System.out.format("toString: %s%n", path.toString());
System.out.format("getFileName: %s%n", path.getFileName());
System.out.format("getName(0): %s%n", path.getName(0));
System.out.format("getNameCount: %d%n", path.getNameCount());
System.out.format("subpath(0,2): %s%n", path.subpath(0,2));
System.out.format("getParent: %s%n", path.getParent());
System.out.format("getRoot: %s%n", path.getRoot());
Here is the output for both Windows and the Solaris OS:
Method Invoked | Returns in the Solaris OS | Returns in Microsoft Windows | Comment |
---|
toString | /home/joe/foo | C:\home\joe\foo | Returns the string representation of the Path. If the path was created using Filesystems.getDefault().getPath(String) or Paths.get (the latter is a convenience method for getPath), the method performs minor syntactic cleanup. For example, in a UNIX operating system, it will correct the input string //home/joe/foo to /home/joe/foo. |
getFileName | foo | foo | Returns the file name or the last element of the sequence of name elements. |
getName(0) | home | home | Returns the path element corresponding to the specified index. The 0th element is the path element closest to the root. |
getNameCount | 3 | 3 | Returns the number of elements in the path. |
subpath(0,2) | home/joe | home\joe | Returns the subsequence of the Path (not including a root element) as specified by the beginning and ending indexes. |
getParent | /home/joe | \home\joe | Returns the path of the parent directory. |
getRoot | / | C:\ | Returns the root of the path. |