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