Create Path from URI in Java

Description

The following code shows how to create Path from URI.

Example


import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
//from   w w  w.  j a va 2  s. c o  m
public class Main {

  public static void main(String[] args) throws Exception{
    Path p = Paths.get(new URI("file:///tmp.txt"));
  System.out.println(p);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode