Java Path Resolve nio resolveForSymbolic(final Path path)

Here you can find the source of resolveForSymbolic(final Path path)

Description

resolve For Symbolic

License

Apache License

Declaration

public static Path resolveForSymbolic(final Path path) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static Path resolveForSymbolic(final Path path) throws IOException {
        if (Files.isSymbolicLink(path)) {
            final Path simLink = Files.readSymbolicLink(path);
            if (!simLink.isAbsolute()) {
                // Resolve the path such that the path is relative to the symbolically
                // linked file's directory
                final Path symLinkParent = path.toAbsolutePath().getParent();
                return symLinkParent.resolve(simLink);
            }//from w w w.  ja v  a2 s .  co  m

            return simLink;
        }
        return path;
    }
}

Related

  1. resolve(Path file, Path srcDir, Path destDir)
  2. resolve(Path path1, Path path2)
  3. resolve(Path target, Collection paths)
  4. resolve(Path workingDir, List paths, String file)
  5. resolveBagUri(final Path baseDir, final URI bagUri)
  6. resolveMaxStep(String rootPath)
  7. resolvePath(final Path baseDirPath, final Path userPath)
  8. resolvePathElements(final Path path)
  9. resolveSymLink(Path link)