Java tutorial
//package com.java2s; public class Main { public static String getRealPath(String real_root, String root, String path) { if (path.equals(root)) { return real_root; } String real_path = (real_root.equals("/") ? "" : real_root) + path.substring(root.equals("/") ? 0 : root.length()); return real_path; } }