net.sf.fmj.utility
Class URLUtils

java.lang.Object
  extended by net.sf.fmj.utility.URLUtils

public final class URLUtils
extends java.lang.Object

URL utilities.

Author:
Ken Larson

Method Summary
static java.lang.String createAbsoluteFileUrl(java.lang.String urlStr)
          returns null if file does not exist.
static java.lang.String createUrlStr(java.io.File file)
           
static java.lang.String extractValidNewFilePathFromFileUrl(java.lang.String url)
          same as extractValidPathFromFileUrl, but checks if parent dir is valid, not file itself.
static java.lang.String extractValidPathFromFileUrl(java.lang.String url)
          Handles the various violations of the file URL format that are commonplace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createAbsoluteFileUrl

public static java.lang.String createAbsoluteFileUrl(java.lang.String urlStr)
returns null if file does not exist.


createUrlStr

public static java.lang.String createUrlStr(java.io.File file)

extractValidPathFromFileUrl

public static java.lang.String extractValidPathFromFileUrl(java.lang.String url)
Handles the various violations of the file URL format that are commonplace. For example, file://home/ken/foo.txt really refers to the relative path home/ken/foo.txt, not /home/ken/foo.txt. But we need to be able to handle it. Assumes the local file system, checks for existance for help.

Parameters:
url -
Returns:
the file path, null if no valid path found.

extractValidNewFilePathFromFileUrl

public static java.lang.String extractValidNewFilePathFromFileUrl(java.lang.String url)
same as extractValidPathFromFileUrl, but checks if parent dir is valid, not file itself. Intended for new files about to be created.