Path.toUri() has the following syntax.
URI toUri()
In the following code shows how to use Path.toUri() method.
import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; /*from w w w. j ava2s. c o m*/ public class Main { public static void main(String[] args) { Path path = Paths.get("C:", "tutorial/Java/JavaFX", "Topic.txt"); //convert path to an URI (browser format) URI path_to_uri = path.toUri(); System.out.println("Path to URI: " + path_to_uri); } }
The code above generates the following result.