Java IO Tutorial - 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;
//from w  ww .j  a  v  a2  s  . 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.