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








Syntax

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

boolean endsWith(String other)

Example

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

//w w  w .  jav a  2  s. c  o m

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {

    public static void main(String[] args) {

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



        boolean ew = path01.endsWith("Topic.txt");
        
        System.out.println(ew);
        
    }
}

The code above generates the following result.