Here you can find the source of relativePath(final File root, final File file)
public static String relativePath(final File root, final File file)
//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(); } }