This is a java program to check protocol is http or not.
URLProtocolDemo.java
import java.net.*;
public class URLProtocolDemo{
public static void main(String[] args){
//String url="https://www.w3schools.com/html/";
try{
URL url=new URL(url);
String protocol= url.getProtocol();
System.out.println("Protocol of given url is : "+protocol);
if(protocol.equalsIgnoreCase("https"));
System.out.println("Protocol is a https protocol");
}
else{
if(protocol.equalsIgnoreCase("http")){
System.out.println("Protocol is a http protocol");
}
else{
System.out.println("Protocol is neither http nor https protocol ");
}
}
catch(Exception e) {
System.out.println(e);
}
}
}