Java Paths get Path

Description

Java Paths get Path


import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) {
    try {/* w  ww .j  av  a 2 s.co m*/
      Path path = Paths.get("c:/", "docs", "users.txt");
      System.out.printf("Absolute path: %s", path.toAbsolutePath());
    } catch (InvalidPathException ex) {
      System.out.printf("Bad path: [%s] at position %s", ex.getInput(), ex.getIndex());
    }

  }
}



PreviousNext

Related