Check if the URI is Opaque in Java
Description
The following code shows how to check if the URI is Opaque.
A URI is opaque if, and only if, it is absolute and its scheme-specific part does not begin with a slash character ('/').
An opaque URI has a scheme, a scheme-specific part, and possibly a fragment; all other components are undefined.
Example
//from www . j ava2 s .co m
import java.net.URI;
public class Main {
public static void main(String args[]) throws Exception {
URI u = new URI("mailto:java-net@java.sun.com");
System.out.println("The URI is " + u);
if (u.isOpaque()) {
System.out.println("This is an opaque URI.");
} else {
System.out.println("This is a hierarchical URI.");
}
}
}
The code above generates the following result.