Java Relative Path Get relativize(String path, String base)

Here you can find the source of relativize(String path, String base)

Description

Returns the path relative to the base.

License

Apache License

Parameter

Parameter Description
patha a parameter
pathb a parameter

Declaration

public static String relativize(String path, String base) 

Method Source Code


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

import java.io.File;

public class Main {
    /**/*w  w w. ja v a2  s . c o  m*/
     * Returns the path relative to the base.
     * 
     * @param patha
     * @param pathb
     * @return
     */
    public static String relativize(String path, String base) {
        return new File(base).toURI().relativize(new File(path).toURI()).getPath();
    }
}

Related

  1. relativize(File home, File f)
  2. relativize(File path, File relative)
  3. relativize(final File root, final File target)
  4. relativize(String path)
  5. relativize(String path)
  6. relativizePath(File from, File to)
  7. relativizePath(final File path, final File base)
  8. relativizePath(String parent, String child)
  9. relativizePathSegments(String[] srcSegments, String[] destSegments)