Java IO Tutorial - 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;
/*  ww w.  j  ava 2 s. c  o m*/
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.