Java Path Relative nio getRelativeFilePathToCwd(File file)

Here you can find the source of getRelativeFilePathToCwd(File file)

Description

get Relative File Path To Cwd

License

Apache License

Declaration

public static String getRelativeFilePathToCwd(File file) 

Method Source Code


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

import java.io.File;
import java.net.URI;

import java.nio.file.Paths;

public class Main {
    public static String getRelativeFilePathToCwd(File file) {
        URI baseUri = Paths.get(".").toUri();
        URI fileUri = file.toURI();
        URI relativeUri = baseUri.relativize(fileUri);
        return relativeUri.getPath();
    }/*from  w  w w . j  a v  a  2s . c  o m*/
}

Related

  1. get(File basePath, String... relatives)
  2. getChildEntryRelativePath(Path base, Path child, boolean convertToLinuxPath)
  3. getFileFromBaseFileAndPathThatMayBeRelative(File baseDir, String pathThatMayBeRelative)
  4. getFileRelativeFolders(Path basePath, Path filePath)
  5. getOptionalPathRelativeToMavenProjectRoot(File absoluteFile)
  6. getRelativePath(File baseFile, File file, String resultIfImpossible)
  7. getRelativePath(File basePath, File path)
  8. getRelativePath(File root, File f)
  9. getRelativePath(final File file, final File baseDir)