URL getProtocol Example
URL class getProtocol example. This example shows you how to use getProtocol method.
URL class getProtocol example. public String getProtocol() Gets the protocol name of this URL.
Here is the code
/*
* @ # GetProtocol.java
* A class repersenting use to getProtocol method
* of URL class in java.net package
* version 24 June 2008
* author Rose India
*/
import java.net.*;
public class GetProtocol {
public static void main(String args[]) throws Exception {
URL url = new URL("http://java.sun.com/javase/6/docs/api/");
System.out.println("Protocol " + url.getProtocol());
}
} |
|