Locating the Target of a Link - Java File Path IO

Java examples for File Path IO:Symbolic Link

Description

Locating the Target of a Link

Demo Code

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
  public static void main(String[] args) {

    Path link = FileSystems.getDefault().getPath("my");

    try {/*from w w w .  ja  v  a2s. c  o  m*/
      Path linkedpath = Files.readSymbolicLink(link);
      System.out.println(linkedpath.toString());
    } catch (IOException e) {
      System.err.println(e);
    }

  }
}

Result


Related Tutorials