org.objectweb.easybeans.util.url
Class URLUtils

java.lang.Object
  extended by org.objectweb.easybeans.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.
 
Constructor Summary
private URLUtils()
          Utility class.
 
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.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
Constructor Detail

URLUtils

private URLUtils()
Utility class.

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