|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xmlmind.fo.util.URLUtil
public final class URLUtil
A collection of utility functions (static methods) operating on URLs.
| Method Summary | |
|---|---|
static String |
fileToLocation(File file)
Converts specified filename to the string form of a "file:" URL. |
static URL |
fileToURL(File file)
Converts specified filename to a "file:" URL. |
static String |
getMIMEType(String location)
Returns the MIME type of the file found at specified location (typically an "http" URL). |
static String |
locationOrFilename(String spec)
Converts specified URL string form or the path of an existing file to an URL string form. |
static File |
locationToFile(String location)
Converts specified "file:" URL to a filename. |
static String |
locationToFilename(String location)
Converts specified "file:" URL to a filename. |
static String |
normalizeMIMEType(String format)
Returns specified MIME type after ``normalizing'' it. |
static InputStream |
openStream(String location)
Opens the stream corresponding to specified location. |
static URL |
urlOrFile(String spec)
Converts specified URL string form or the path of an existing file to an URL. |
static File |
urlToFile(URL url)
Converts specified "file:" URL to a filename. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static URL fileToURL(File file)
public static String fileToLocation(File file)
public static File urlToFile(URL url)
url - URL to be converted
null if url is not a "file:" URL.public static File locationToFile(String location)
location - string form of the URL to be converted
null if location is not a "file:" URL.public static String locationToFilename(String location)
location - string form of the URL to be converted
null if location is not a "file:" URL.public static URL urlOrFile(String spec)
spec - the string form of an URL or
the path of an existing file (not a directory).
null if spec
cannot be converted to an URLpublic static String locationOrFilename(String spec)
spec - the string form of an URL or
the path of an existing file (not a directory).
public static String getMIMEType(String location)
location - an absolute URL in its string form.
null if this MIME type cannot be determined.normalizeMIMEType(java.lang.String)public static String normalizeMIMEType(String format)
For example, returns "text/html" for "TEXT/HTML; CHARSET=UTF-8".
Other example, returns "image/jpeg" for "image/jpg".
public static InputStream openStream(String location)
throws IOException,
MalformedURLException
This function supports "data:" locations.
location - the string form of an URL
MalformedURLException - if location
cannot be parsed as an URL
IOException - if an I/O error occurs during the operation
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||