Java Relative Path Get relativePath(final File root, final File file)

Here you can find the source of relativePath(final File root, final File file)

Description

artifact path from root/file relation

License

BSD License

Declaration

public static String relativePath(final File root, final File file) 

Method Source Code

//package com.java2s;
/**//www .j  av a2s .co m
 * Copyright (C) 2010-2012 Andrei Pozolotin <Andrei.Pozolotin@gmail.com>
 *
 * All rights reserved. Licensed under the OSI BSD License.
 *
 * http://www.opensource.org/licenses/bsd-license.php
 */

import java.io.File;

public class Main {
    /** artifact path from root/file relation */
    public static String relativePath(final File root, final File file) {

        return root.toURI().relativize(file.toURI()).getPath();

    }
}

Related

  1. relativePath(File parent, File child)
  2. relativePath(File parent, File child)
  3. relativePath(File path, File relativeTo)
  4. relativePath(File root, File node)
  5. relativePath(File src, File dest)
  6. relativePath(final String inputPath, final File file)
  7. relativePath(String origin, String target)
  8. relativePath(String p_absolutePath, String p_currentPath)
  9. relativePathFiles(String relativePath, final String... fileNamesRegex)