public final class URLTools
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
browse(java.net.URI uri)
Launches the default system handler for the given URI.
|
static boolean |
browse(java.net.URL url)
Opens the system default browser for the given URL.
|
static void |
downloadUrlToFile(java.net.URL sourceUrl,
java.io.File destination,
int connectTimeoutMs,
int readTimeoutMs)
Downloads content from a remote URL directly to a destination file.
|
static javax.swing.event.HyperlinkListener |
getHyperlinkListener()
Returns a shared
HyperlinkListener that opens activated links in the system default browser. |
static boolean |
openURL(java.net.URL url)
Attempts to open the URL using desktop integration, falling back to registered content handlers.
|
static java.lang.String |
readFromURL(java.lang.String url)
Drains the resource content at the given URL into a String using UTF-8.
|
static java.lang.String |
readFromURL(java.lang.String url,
java.lang.String encoding)
Drains the resource content at the given URL into a String using the specified encoding.
|
static java.util.Map<java.lang.String,java.lang.String> |
splitQuery(java.net.URL url)
Parses and URL-decodes query parameters into an insertion-ordered map.
|
public static javax.swing.event.HyperlinkListener getHyperlinkListener()
HyperlinkListener that opens activated links in the system default browser.public static boolean browse(java.net.URL url)
url - the URL to browsetrue if successfully launchedpublic static boolean browse(java.net.URI uri)
uri - the URI to browsetrue if successfully dispatchedpublic static boolean openURL(java.net.URL url)
url - the target URLtrue if opened successfullypublic static java.util.Map<java.lang.String,java.lang.String> splitQuery(java.net.URL url)
Parameters without values (e.g. ?flag) map to an empty string.
url - URL to extract parameters fromMissingArgumentException - if url is nullpublic static java.lang.String readFromURL(java.lang.String url)
throws java.net.MalformedURLException,
java.io.IOException
java.net.MalformedURLExceptionjava.io.IOExceptionpublic static java.lang.String readFromURL(java.lang.String url,
java.lang.String encoding)
throws java.net.MalformedURLException,
java.io.IOException
url - endpoint URL stringencoding - character encoding nameMissingArgumentException - if url or encoding is nulljava.net.MalformedURLException - if the endpoint string is invalidjava.io.IOException - on transmission failurepublic static void downloadUrlToFile(java.net.URL sourceUrl,
java.io.File destination,
int connectTimeoutMs,
int readTimeoutMs)
throws java.io.IOException
sourceUrl - the HTTP/HTTPS endpoint to retrievedestination - the target file on diskconnectTimeoutMs - connection timeout in millisecondsreadTimeoutMs - read timeout in millisecondsMissingArgumentException - if sourceUrl or destination is nulljava.io.IOException - if network transmission failsIRuntimeException - wrapping file I/O or storage synchronization failuresCopyright © 2000-2026 OAshi S.à r.l. All Rights Reserved.