Is there a class whene HTTP and HTTPs constant value is defined. As of now I have created a custom class.
public static class UrlConstants {
private UrlConstants() {
super();
}
/** The Constant HTTP. */
public static final String HTTP = "http";
}
As far as I can tell (as of JDK 8 which I have handy), the best you can do within the Java JDK is
javax.print.attribute.standard.ReferenceUriSchemesSupported
which provides a number of URI-Schemes:
import javax.print.attribute.standard.ReferenceUriSchemesSupported;
// ...
System.out.println(ReferenceUriSchemesSupported.HTTPS); // => "https"
Of course, it also has GOPHER, NNTP, NEWS, and a few other out-of-date schemes, but it does provide what you want.
Other answers on the web suggest other frameworks, many of which do define the two protocols.
Otherwise, you just need something like this:
package demo;
public enum Scheme {
HTTP("http"),
HTTPS("https");
private final String scheme;
private Scheme(String scheme) {
this.scheme = scheme;
}
@Override
public String toString() {
return scheme;
}
}
A little clunky, but these work.
String.valueOf(org.apache.commons.httpclient.HttpURL.DEFAULT_SCHEME)
String.valueOf(org.apache.commons.httpclient.HttpsURL.DEFAULT_SCHEME)
There's also org.mortbay.jetty.HttpSchemes.HTTP and org.mortbay.jetty.HttpSchemes.HTTPS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With