Java tutorial
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static String toPath(File root, File dir) { String path = dir.getAbsolutePath(); path = path.substring(root.getAbsolutePath().length()).replace(File.separatorChar, '/'); if (path.startsWith("/")) { path = path.substring(1); } if (dir.isDirectory() && !path.endsWith("/")) { path += "/"; } return path; } }