public static String getAbsoluteURIFromRelative(String localPath)
  {
    if (localPath == null || localPath.length() == 0)
      return "";

    // If the local path is a relative path, then it is resolved against
    // the "user.dir" system property.
    String absolutePath = localPath;
    if (!isAbsolutePath(localPath))
    {
      try
      {
        absolutePath = getAbsolutePathFromRelativePath(localPath);
      }
      // user.dir not accessible from applet
      catch (SecurityException se)
      {
        return "file:" + localPath;
      }
    }

    String urlString;
    if (null != absolutePath)
    {
      if (absolutePath.startsWith(File.separator))
        urlString = "file://" + absolutePath;
      else
        urlString = "file:///" + absolutePath;
    }
    else
      urlString = "file:" + localPath;

    return replaceChars(urlString);
  }
public static String getAbsoluteURIFromRelative ( String localPath ) { if ( localPath == null || localPath . length ( ) == 0 ) return "" ; String absolutePath = localPath ; if ( ! isAbsolutePath ( localPath ) ) { try { absolutePath = getAbsolutePathFromRelativePath ( localPath ) ; } catch ( SecurityException se ) { return "file:" + localPath ; } } String urlString ; if ( null != absolutePath ) { if ( absolutePath . startsWith ( File . separator ) ) urlString = "file://" + absolutePath ; else urlString = "file:///" + absolutePath ; } else urlString = "file:" + localPath ; return replaceChars ( urlString ) ; }
Get an absolute URI from a given relative URI (local path).

<p>The relative URI is a local filesystem path. The path can be
absolute or relative. If it is a relative path, it is resolved relative
to the system property "user.dir" if it is available; if not (i.e. in an
Applet perhaps which throws SecurityException) then we just return the
relative path. The space and backslash characters are also replaced to
generate a good absolute URI.</p>

@param localPath The relative URI to resolve

@return Resolved absolute URI