org.ow2.util.url
Class URLUtils

java.lang.Object
  extended by org.ow2.util.url.URLUtils

public final class URLUtils
extends java.lang.Object

This class is used to :

In fact, when there are spaces in a directory name, file.toURL() doesn't escape spaces into %20, this is why this class will help.
This class has to be used both for encoding and decoding URL.
There are methods with checked exceptions or unchecked exceptions.

Author:
Florent Benoit

Field Summary
static java.lang.String FILE_PROTOCOL
          File protocol.
 
Method Summary
static java.net.URL fileToURL(java.io.File file)
          Gets an URL from a given file.(throws only runtime exception).
static java.net.URL fileToURL2(java.io.File file)
          Gets an URL from a given file.
static java.lang.String shorterName(java.net.URL url)
          For a given URL, make a shorter name.
static java.io.File urlToFile(java.net.URL url)
          Gets a File object for the given URL.
static java.io.File urlToFile2(java.net.URL url)
          Gets a File object for the given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_PROTOCOL

public static final java.lang.String FILE_PROTOCOL
File protocol.

See Also:
Constant Field Values
Method Detail

fileToURL

public static java.net.URL fileToURL(java.io.File file)
Gets an URL from a given file.(throws only runtime exception).

Parameters:
file - the given file
Returns:
the URL that has been built

fileToURL2

public static java.net.URL fileToURL2(java.io.File file)
                               throws URLUtilsException
Gets an URL from a given file.

Parameters:
file - the given file
Returns:
the URL that has been built
Throws:
URLUtilsException - if the URL cannot be get from file.

urlToFile

public static java.io.File urlToFile(java.net.URL url)
Gets a File object for the given URL.

Parameters:
url - the given url.
Returns:
File object

urlToFile2

public static java.io.File urlToFile2(java.net.URL url)
                               throws URLUtilsException
Gets a File object for the given URL.

Parameters:
url - the given url.
Returns:
File object
Throws:
URLUtilsException - if File cannot be get from URL

shorterName

public static java.lang.String shorterName(java.net.URL url)
For a given URL, make a shorter name.

Parameters:
url - the given URL
Returns:
a short name for the given URL


Copyright © 2007-2009 OW2 Consortium. All Rights Reserved.