Converting between path types - Java File Path IO

Java examples for File Path IO:Path

Description

Converting between path types

Demo Code

import java.io.IOException;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) {
    try {//w  w  w  .  j  av a  2s  .co m
      Path path;
      path = Paths.get("users.txt");
      System.out.println("URI path: " + path.toUri());
      System.out.println("Absolute path: " + path.toAbsolutePath());
      System.out.println("Real path: "
          + path.toRealPath(LinkOption.NOFOLLOW_LINKS));
    } catch (IOException ex) {
    }
  }

}

Related Tutorials