code: private static String matchPathLists(List<String> basePath, List<String> filePath) {
          // start at the beginning of the lists
          // iterate while both lists are equal
          final StringBuilder relativePath = new StringBuilder();
          final ListIterator<String> basePathItr = basePath.listIterator(basePath.size() - 1);
          final ListIterator<String> filePathItr = filePath.listIterator(filePath.size() - 1);
          
          // first eliminate common root elements
          while (basePathItr.hasPrevious() && filePathItr.hasPrevious()) {
              if (!basePathItr.previous().equals(filePathItr.previous())) {
                  basePathItr.next();
                  filePathItr.next();
                  break;
              }
          }
  
          // for each remaining level in the home path, add a ..
          for (; basePathItr.hasPrevious(); basePathItr.previous()) {
              relativePath.append("..").append(File.separator);
          }
  
          // for each level in the file path, add the path
          while (filePathItr.hasPrevious()) {
              relativePath.append(filePathItr.previous());
              if (filePathItr.hasPrevious()) {
                  relativePath.append(File.separator);
              }
          }
  
          return relativePath.toString();
      }
docs: figure out a string representing the relative path of
  'f' with respect to 'r'
  @param basePath home path
  @param filePath path of file