Java Path Relative nio isRelativized(final Path base, final String successor)

Here you can find the source of isRelativized(final Path base, final String successor)

Description

is Relativized

License

Apache License

Declaration

public static boolean isRelativized(final Path base, final String successor) 

Method Source Code


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

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;

public class Main {
    public static boolean isRelativized(final Path base, final String successor) {
        return isRelativized(base, Paths.get(successor));
    }/*from w  ww.  j  a  v a2s  .co m*/

    public static boolean isRelativized(final Path base, final Path successor) {
        Objects.requireNonNull(base);
        Objects.requireNonNull(successor);

        final Path baseNormalized = base.normalize();
        final Path successorNormalized = successor.normalize();
        return baseNormalized.relativize(baseNormalized.resolve(successorNormalized)).equals(successorNormalized);
    }
}

Related

  1. getRelativePath(String file, String directory)
  2. getRelativePath(String fullPath, String homeFolderPath)
  3. getRelativePath(String relativePathFile)
  4. getSourceFileRelativePath(Class declaringClass)
  5. isRelativePath(Path baseDir, Path file)
  6. relativePath(String input, String mainurl)
  7. relativePathTo(Path path, Path basePath)
  8. relativize(Path absoluteDirectory, Path subDirectory)
  9. relativize(Path target, Collection paths)