Package arcommon.net
Class NetUtil
- java.lang.Object
-
- arcommon.net.NetUtil
-
public class NetUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEMAIL_PROTOCOLstatic java.lang.StringPHONE_PROTOCOL
-
Constructor Summary
Constructors Constructor Description NetUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckUnlimitedCipher()static java.lang.StringdecodeCookieElement(java.lang.String cookieElement)static java.lang.StringdecodeDomainNameFromIDN(java.lang.String domainName)static java.lang.StringdecodeHtml(java.lang.String string)This method will remove all HTML tags.static java.lang.StringdecodeUrlFormData(java.lang.String url)static java.lang.StringdecodeUrlPath(java.lang.String url)static java.lang.StringdecodeUrlToDisplayString(java.lang.String urlString)This method will return the urlString parameter URL in a displayable / human-readable format.static java.lang.StringdownloadContentOf(java.lang.String urlString)static voiddownloadFile(java.lang.String urlString, java.lang.String fileName)static java.lang.StringencodeCookieName(java.lang.String cookieName)static java.lang.StringencodeCookieValue(java.lang.String cookieValue)static java.lang.StringencodeDomainNameToIDN(java.lang.String domainName)static java.lang.StringencodeUrlFormData(java.lang.String url)This will encode ' ' as '+' and that will properly not work, if it is used before the '?' in the URL.static java.lang.StringencodeUrlMyVariant(java.lang.String url)This method will return the encoding the entire URL (if needed).static java.lang.StringencodeUrlPath(java.lang.String path)This will encode ' ' as "%20" and that will properly not work, if it is used after the '?' in the URL.static booleanisUrlValid(java.lang.String url)Returns true if the url parameter is a valid URL.static booleanopenBrowser(java.lang.String url)static voidopenBrowserWithDialog(java.lang.String url)static voidtrustAllHttpsCertificates()
-
-
-
Field Detail
-
EMAIL_PROTOCOL
public static final java.lang.String EMAIL_PROTOCOL
- See Also:
- Constant Field Values
-
PHONE_PROTOCOL
public static final java.lang.String PHONE_PROTOCOL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NetUtil
public NetUtil()
-
-
Method Detail
-
trustAllHttpsCertificates
public static void trustAllHttpsCertificates()
-
checkUnlimitedCipher
public static void checkUnlimitedCipher()
-
openBrowserWithDialog
public static void openBrowserWithDialog(java.lang.String url)
-
openBrowser
public static boolean openBrowser(java.lang.String url)
-
isUrlValid
public static boolean isUrlValid(java.lang.String url)
Returns true if the url parameter is a valid URL.
Note: This method will return true on phone numbers (tel:) even though new URL("tel:+45%2020") will throw a MalformedURLException.
-
decodeUrlToDisplayString
public static java.lang.String decodeUrlToDisplayString(java.lang.String urlString)
This method will return the urlString parameter URL in a displayable / human-readable format.
Note: E-mails (mailto:) and phone numbers (tel:) will be "displayed" (=returned) without protocol.
Note: This is not the (complete) reversed function ofencodeUrlMyVariant(String)
encodeUrlMyVariant(decodeUrlToDisplayString(urlString)) != urlString
-
decodeDomainNameFromIDN
public static java.lang.String decodeDomainNameFromIDN(java.lang.String domainName)
- See Also:
encodeDomainNameToIDN(String)
-
decodeUrlFormData
public static java.lang.String decodeUrlFormData(java.lang.String url)
-
decodeUrlPath
public static java.lang.String decodeUrlPath(java.lang.String url)
-
encodeUrlMyVariant
public static java.lang.String encodeUrlMyVariant(java.lang.String url)
This method will return the encoding the entire URL (if needed).
This method is "stable" e.g. it can be called on it own return value without any change:
encodeUrlMyVariant(url) == encodeUrlMyVariant(encodeUrlMyVariant(url))
-
encodeDomainNameToIDN
public static java.lang.String encodeDomainNameToIDN(java.lang.String domainName)
-
encodeUrlFormData
public static java.lang.String encodeUrlFormData(java.lang.String url)
This will encode ' ' as '+' and that will properly not work, if it is used before the '?' in the URL.- See Also:
see encodeUrlPath for a method that encodes ' ' as "%20" which will properly not work, if it is used after the '?',see encodeUrlMyVariant for a method that will encode the entire URL (if needed),decodeUrlFormData(String),decodeUrlPath(String),decodeUrlToDisplayString(String),XmlUtil.encodeXmlString(String),XmlUtil.decodeXmlString(String)
-
encodeUrlPath
public static java.lang.String encodeUrlPath(java.lang.String path)
This will encode ' ' as "%20" and that will properly not work, if it is used after the '?' in the URL.- See Also:
see encodeUrlFormData for a method that encodes ' ' as '+' which will properly not work, if it is used before the '?',see encodeUrlMyVariant for a method that will encode the entire URL (if needed),decodeUrlFormData(String),decodeUrlPath(String),decodeUrlToDisplayString(String),XmlUtil.encodeXmlString(String),XmlUtil.decodeXmlString(String)
-
decodeCookieElement
public static java.lang.String decodeCookieElement(java.lang.String cookieElement)
-
encodeCookieName
public static java.lang.String encodeCookieName(java.lang.String cookieName)
-
encodeCookieValue
public static java.lang.String encodeCookieValue(java.lang.String cookieValue)
-
decodeHtml
public static java.lang.String decodeHtml(java.lang.String string)
This method will remove all HTML tags.
-
downloadContentOf
public static java.lang.String downloadContentOf(java.lang.String urlString)
-
downloadFile
public static void downloadFile(java.lang.String urlString, java.lang.String fileName)
-
-