Create a path from URI in Java

Description

The following code shows how to create a path from URI.

Example


//from   ww w  .j a v a  2s. co  m
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {

  public static void main(String[] args) throws Exception {
    Path path = Paths.get(new URI("file:///C:/home/docs/users.txt"));
    System.out.println("subpath: " + path);

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode