Java IO Tutorial - Java Path.resolveSibling(String other)








Syntax

Path.resolveSibling(String other) has the following syntax.

Path resolveSibling(String other)

Example

In the following code shows how to use Path.resolveSibling(String other) method.

/*from  ww w.  j  ava 2s . c o m*/
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {

    public static void main(String[] args) {

        //define the fix path
        Path base_1 = Paths.get("C:/tutorial/Java/JavaFX");
        Path base_2 = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt");


        //resolve sibling Demo.txt file
        Path path_3 = base_2.resolveSibling("Demo.txt");
        System.out.println(path_3.toString());

    }

}

The code above generates the following result.