Java Paths.get(String first, String ... more)

Syntax

Paths.get(String first, String ... more) has the following syntax.

public static Path get(String first,  String ... more)

Example

In the following code shows how to use Paths.get(String first, String ... more) method.


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

  public static void main(String[] args) {

    Path path = Paths.get("tutorial/Java/JavaFX/Topic.txt");
    System.out.println(path);
    
    path = Paths.get("/tutorial", "Java/JavaFX/Topic.txt");
    System.out.println(path);
    
    path = Paths.get("C:/tutorial/Java/JavaFX", "Topic.txt");
    System.out.println(path);
    
    path = Paths.get("C:", "tutorial/Java/JavaFX", "Topic.txt");
    System.out.println(path);
    
    path = Paths.get("C:", "tutorial", "Java", "JavaFX", "Topic.txt");
    System.out.println(path);
    
    path = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt");
    System.out.println(path);
    
    path = Paths.get("C:/tutorial/Java/JavaFX/dummy/../Topic.txt").normalize();
    System.out.println(path);
    
    path = Paths.get("C:/tutorial/Java/./JavaFX/dummy/../Topic.txt").normalize();
    System.out.println(path);
    
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio.file »




DirectoryStream.Filter
Files
FileStore
FileSystem
FileVisitor
Path
Paths
WatchService