Sample code for 30+ languages & platforms
Java

Get the Target of a Symbolic Link

See more FileAccess Examples

Demonstrates how to get the target of a symbolic link.

Note: This example requires Chilkat v9.5.0.77 or greater.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    CkFileAccess fac = new CkFileAccess();

    String targetPath = fac.symlinkTarget("qa_data/my_symlink");
    if (fac.get_LastMethodSuccess() != true) {
        System.out.println("Failed to get symlink target.");
        return;
        }

    System.out.println("target path = " + targetPath);
  }
}