Program: 78660
Project: 78660
Buggy source:
/** 
 * Return the relative path for the given <code>resource</code> according to <code>base</code>. Only handle file system. Network protocols such as http, ftp, etc. are not supported. If such cases happens, <code>resource</code> is returned. <p> The <code>base</code> value should be directory ONLY and does NOT contain file name and the format can be: <ul> <li>./../hello/ <li>C:\\hello\..\ <li>/C:/../hello/ </ul> The spearator in the return path is platform-depedent.
 * @param base the base directory
 * @param resource the full path
 * @return the relative path
 */
public static String getRelativePath(String base,String resource){
  String baseDir=getLocalPath(base);
  String resourceDir=getLocalPath(resource);
  if (baseDir == null || resourceDir == null)   return resource;
  File baseFile=new File(baseDir);
  File resourceFile=new File(resourceDir);
  baseDir=baseFile.getAbsolutePath();
  resourceDir=resourceFile.getAbsolutePath();
  int matchedPos=0;
  for (matchedPos=0; matchedPos < baseDir.length() && matchedPos < resourceDir.length(); matchedPos++) {
    if (baseDir.charAt(matchedPos) != resourceDir.charAt(matchedPos))     break;
  }
  if (isLastDirectoryMatched(baseDir,resourceDir,matchedPos) || isLastDirectoryMatched(resourceDir,baseDir,matchedPos))   ;
 else   matchedPos=baseDir.lastIndexOf(File.separator,matchedPos);
  int samePrefixPos=matchedPos;
  int upDirs=0;
  while (matchedPos < baseDir.length() && matchedPos > 0) {
    matchedPos=baseDir.indexOf(File.separator,matchedPos + 1);
    upDirs++;
  }
  StringBuffer sb=new StringBuffer();
  for (int i=0; i < upDirs; i++) {
    sb.append("String_Node_Str" + File.separator);
  }
  if (samePrefixPos < resourceDir.length())   sb.append(resourceDir.substring(samePrefixPos + 1));
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Return the relative path for the given <code>resource</code> according to <code>base</code>. Only handle file system. Network protocols such as http, ftp, etc. are not supported. If such cases happens, <code>resource</code> is returned. <p> The <code>base</code> value should be directory ONLY and does NOT contain file name and the format can be: <ul> <li>./../hello/ <li>C:\\hello\..\ <li>/C:/../hello/ </ul> The spearator in the return path is platform-depedent. Please note that the <code>File.separator</code> in the end of directory will be striped in the return value.
 * @param base the base directory
 * @param resource the full path
 * @return the relative path.
 */
public static String getRelativePath(String base,String resource){
  String baseDir=getLocalPath(base);
  String resourceDir=getLocalPath(resource);
  if (baseDir == null || resourceDir == null)   return resource;
  File baseFile=new File(baseDir);
  File resourceFile=new File(resourceDir);
  baseDir=baseFile.getAbsolutePath();
  resourceDir=resourceFile.getAbsolutePath();
  int matchedPos=0;
  for (matchedPos=0; matchedPos < baseDir.length() && matchedPos < resourceDir.length(); matchedPos++) {
    if (baseDir.charAt(matchedPos) != resourceDir.charAt(matchedPos))     break;
  }
  if (isLastDirectoryMatched(baseDir,resourceDir,matchedPos) || isLastDirectoryMatched(resourceDir,baseDir,matchedPos))   ;
 else   matchedPos=baseDir.lastIndexOf(File.separator,matchedPos);
  int samePrefixPos=matchedPos;
  int upDirs=0;
  while (matchedPos < baseDir.length() && matchedPos > 0) {
    matchedPos=baseDir.indexOf(File.separator,matchedPos + 1);
    upDirs++;
  }
  StringBuffer sb=new StringBuffer();
  for (int i=0; i < upDirs; i++) {
    sb.append("String_Node_Str" + File.separator);
  }
  if (samePrefixPos < resourceDir.length())   sb.append(resourceDir.substring(samePrefixPos + 1));
  int len=sb.length();
  if (len > 0) {
    char lastChar=sb.charAt(len - 1);
    if (lastChar == File.separatorChar)     sb.deleteCharAt(len - 1);
  }
  return sb.toString();
}