Here you can find the source of getRelativeName(File file, URI directory)
public static String getRelativeName(File file, URI directory) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.net.URI; public class Main { public static String getRelativeName(File file, URI directory) throws IOException { URI fUri = file.toURI();//ww w . j a v a2s .c o m return directory.relativize(fUri).getPath(); } }