code: public static String getRelativePathName(Path root, Path path) {
          Path relative = root.relativize(path);
          return Files.isDirectory(path) && !relative.toString().endsWith("/") ? String.format("%s/", relative.toString()) : relative.toString();
      }
docs: Get the relative path of an application
  
  @param root the root to relativize against
  @param path the path to relativize
  @return the relative path