Java Path Relative nio getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath)

Here you can find the source of getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath)

Description

get Child Entry Relative Path

License

Apache License

Declaration

public static String getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath) 

Method Source Code

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

import java.nio.file.*;

public class Main {
    public static String getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath) {
        String path = base.toUri().relativize(child.toUri()).getPath();
        if (convertToLinuxPath && !"/".equals(base.getFileSystem().getSeparator())) {
            return path.replace(base.getFileSystem().getSeparator(), "/");
        } else {//w w  w .ja  va2s.c  om
            return path;
        }
    }
}

Related

  1. checkNormalizedRelative(String path)
  2. combinePaths(String baseDir, String relativePath)
  3. get(File basePath, String... relatives)
  4. getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)
  5. getFileRelativeFolders(Path basePath, Path filePath)
  6. getOptionalPathRelativeToMavenProjectRoot(File absoluteFile)
  7. getRelativeFilePathToCwd(File file)