Java Utililty Methods URI Value Check

List of utility methods to do URI Value Check

Description

The list of methods to do URI Value Check are organized into topic(s).

Method

booleanisURI(String plainString)
is URI
try {
    URL url = new URL(plainString);
    URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(),
            url.getQuery(), url.getRef());
    return true;
} catch (URISyntaxException | MalformedURLException e) {
    return false;
booleanisURI(String uri)

isURI.

try {
    new URI(uri);
    return true;
} catch (URISyntaxException e) {
    return false;
booleanisUriValid(String uri)
is Uri Valid
uri = uri.trim();
if (responseCodeOfURI(uri) == 200)
    return true;
return false;
booleanisUsingNonDefaultPort(URI uri)
Returns true if the specified URI is using a non-standard port (i.e.
String scheme = uri.getScheme().toLowerCase();
int port = uri.getPort();
if (port <= 0)
    return false;
if (scheme.equals("http") && port == 80)
    return false;
if (scheme.equals("https") && port == 443)
    return false;
...
booleanisValid(String uri)
is Valid
try {
    return isValid(new URI(uri));
} catch (URISyntaxException e) {
    return false;
booleanisValid(URI uri)
is Valid
if (isEmpty(uri.getScheme()) || isEmpty(uri.getHost()) || uri.getPort() == -1) {
    return false;
return true;
booleanisValidURI(final String namespace)
Determine if the supplied name is a valid URI.
if (namespace == null || namespace.length() == 0)
    return false;
try {
    new java.net.URI(namespace);
} catch (final URISyntaxException e) {
    return false;
return true;
...
booleanisValidURI(String uri)
return true if this is a valid uri
boolean result = false;
try {
    new URI(uri);
    result = true;
} catch (Exception e) {
return result;
booleanisValidUri(String uri, StringBuilder errMsg)
Tests whether the given URI matches RFC-2396 specs.
boolean ret = true;
if (uri == null) {
    if (errMsg != null) {
        errMsg.append("URI is null");
    ret = false;
} else {
    try {
...
booleanisValidUri(String uriCandidate)
is Valid Uri
try {
    new URI(uriCandidate);
} catch (URISyntaxException e) {
    return false;
return true;