Here you can find the source of getRelativePath(final File file, final File baseDir)
Parameter | Description |
---|---|
file | The file to create a relative path for. |
baseDir | The base directory the path to the file should be relative to. |
public static Path getRelativePath(final File file, final File baseDir)
//package com.java2s; import java.io.File; import java.nio.file.Path; public class Main { /**/*from w ww . jav a 2 s.c om*/ * Gets the relative from the specified directory to the specified file. * * @param file * The file to create a relative path for. * @param baseDir * The base directory the path to the file should be relative to. * @return * The relative path from the base directory to the specified file. */ public static Path getRelativePath(final File file, final File baseDir) { final Path fileDirPath = file.toPath(); final Path baseDirPath = baseDir.toPath(); return baseDirPath.relativize(fileDirPath); } }