Technoledge

Android Learning, Programing, Game and Aplication. with Programing Language

  • Home
  • Privacy Policy
  • Disclaimer
  • Contact Us
skip to main | skip to sidebar
Home » Java Programming » Taking the port from URL

Taking the port from URL

on Tuesday, January 8, 2013 | 9:08 PM

Taking the port from URL. Port is a 16-bit number to know the services offered by the network server, each service has a port, if you want to access the service shall be connected to the appropriate port, the port has a particular service is called the standard port, eg port 80 http protocol has (80 standard ports), all services have a port number below 1024, whereas port numbers above 1024 are custom port that we use when they want to make a server, so the server should use when making port above 1024

In this article will be given a script that can help you get the port number specified in the URL, to take the first port we create an object of class URL, then created a variable that holds the value of the url given port, then use a method which URL to display port getPort (); Integer port number that is accommodated by a variable of type Integer, then the number is issued to the console, as was done by the script below
--------^^^^^^^^^^^^^^^^^^------------------
package javalearning;
import java.net.*;

public class AmbilPort {
public static void main(String[] args) {
try{
URL url = new URL("http://www.yahoo.com");
Integer protocol = url.getPort();
System.out.println(protokol);
}catch(Exception ue){
}
}
}
---------------------------------------------------
....
Share this post :
Taking the port from URL Published By Technoledge Terima Kasih Telah membaca Taking the port from URL
Link Taking the port from URL Published on: 2013-01-08T21:08:00+07:00
Taking the port from URL . Port is a 16-bit number to know the services offered by the network server, each service has a port, if you want... Rating 5 ★★★★★ Reviews 1110
Labels: Java Programming
« Prev Post Next Post » Home

Sponsor

 
Copyright © 2013. Technoledge - All Rights Reserved
Proudly powered by Blogger