Paths Class

Package: java.nio.file

The Paths class provides a single method (get), which returns a Path object for a given file path string. For more information, see Path Interface.

Method

Method

Description

static Path get(String path)

Returns a path object for the specified path string.

Here’s an example that uses the get method of the static Paths class, like this:

Path p = Paths.get(“c:\test.txt”);

Here, the file’s name is test.txt, and it resides in the root directory of the C: drive.

After it’s created by the get method, the Path object can be used with the Files class to manipulate the file or directory represented by the Path object. For more information, see Files Class.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset