3 November 2021

java.nio.Path

Path This is an interface with a static method of. This method can be called two ways.


jshell> Path p = Path.of("foo", "baz", "bar");
p ==> foo/baz/bar

jshell> Path q = Path.of("foo/baz/bar");
q ==> foo/baz/bar

jshell> p.equals(q)
$3 ==> true

You can use it to create absoltue or relative paths.

You will notice an (abortive) static service class Paths; don't use it. Prefer Path.of.

Paths refer to possible locations in your file system.

Some Useful Methods

java.nio.Files

There are a variety of ways of getting file properties.

Reading a File

Files.newBufferedReader(Path p)