Java Path.subpath(int beginIndex, int endIndex)

Syntax

Path.subpath(int beginIndex, int endIndex) has the following syntax.

Path subpath(int beginIndex,  int endIndex)

Example

In the following code shows how to use Path.subpath(int beginIndex, int endIndex) method.


import java.nio.file.Path;
import java.nio.file.Paths;
//w  ww .ja v a  2  s .c  om
public class Main {

    public static void main(String[] args) {

        Path path = Paths.get("C:", "tutorial/Java/JavaFX", "Topic.txt");

        System.out.println("Subpath (0,3): " + path.subpath(0, 3));
    }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio.file »




DirectoryStream.Filter
Files
FileStore
FileSystem
FileVisitor
Path
Paths
WatchService