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








Syntax

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

Path resolve(String other)

Example

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

/*from w  w  w . jav a 2  s  . 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 Topic.txt file
        Path path_1 = base_1.resolve("Topic.txt");
        System.out.println(path_1.toString());

        //resolve Demo.txt file
        Path path_2 = base_1.resolve("Demo.txt");
        System.out.println(path_2.toString());

    }

}

The code above generates the following result.