java.io.File.toPath() Example



java.io.File.toPath()

Method description:

Returns a java.nio.file.Path object constructed from the this abstract path.
Show method details.

Declaration:

Parameters:

The method has no parameters.

Return value:

a Path constructed from this abstract path

Exceptions:

  • InvalidPathException – if a Path object cannot be constructed from the abstract path (see FileSystem.getPath)
  • Example:

    The following example illustrates the usage of the java.io.File.toPath() method.

    Output:

    If we compile and run this code sample, it will give the following result: