public class ReplaceInURL
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
replaceHost(java.lang.String url,
java.lang.String host)
Replace the host of an URL (like 'www.dkfqs.com' or '192.168.0.50').
|
static java.lang.String |
replacePath(java.lang.String url,
java.lang.String path)
Replace the full path of an URL, inclusive (optional) query string parameters and inclusive (optional) fragment identifier.
|
static java.lang.String |
replacePort(java.lang.String url,
int port)
Replace the IP port of an URL.
|
static java.lang.String |
replacePort(java.lang.String url,
java.lang.String port)
Replace the IP port of an URL.
|
static java.lang.String |
replaceProtocol(java.lang.String url,
java.lang.String protocol)
Replace the protocol of an URL (like 'https' or 'http').
|
public static java.lang.String replaceProtocol(java.lang.String url, java.lang.String protocol) throws java.net.MalformedURLException
url
- the URLprotocol
- the new protocoljava.net.MalformedURLException
- if the passed URL is invalidpublic static java.lang.String replaceHost(java.lang.String url, java.lang.String host) throws java.net.MalformedURLException
url
- the URLhost
- the new hostjava.net.MalformedURLException
- if the passed URL is invalidpublic static java.lang.String replacePort(java.lang.String url, int port) throws java.net.MalformedURLException, java.lang.IllegalArgumentException
url
- the URLport
- the new IP port (0..65335)java.net.MalformedURLException
- if the passed URL is invalidjava.lang.IllegalArgumentException
- if the IP port is out of valid rangepublic static java.lang.String replacePort(java.lang.String url, java.lang.String port) throws java.net.MalformedURLException, java.lang.IllegalArgumentException
url
- the URLport
- the new IP port as a String (converted to int number: 0..65335)java.net.MalformedURLException
- if the passed URL is invalidjava.lang.IllegalArgumentException
- if the IP port is out of valid range, or cannot converted to an int numberpublic static java.lang.String replacePath(java.lang.String url, java.lang.String path) throws java.net.MalformedURLException
url
- the URLpath
- the new full path of the URL, inclusive (optional) query string parameters and inclusive (optional) fragment identifierjava.net.MalformedURLException
- if the passed URL is invalid