Powered by Blogger.

Monday 2 February 2015

URL

No comments :
URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet. The URL class provides a simple, concise API to access information across the Internet using URLs. A URL has four main components:The first is the protocol to use, separated from the reset of the locator by a colon (;). Component protocols are HTTP, FTP, gopher, and file, although these days almost everything is being done via HTTP (in fact, most browsers will proceed correctly if you leave off the "http://" form your URL specification). The second component is the host name or IP address of the host to use; this is delimited on the left by double slashes (//) and on the right by a slashes (/ ) or optional a colon (;). The third component, the port number, is an optional parameter, delimited on the left form the host name by a cokon (:) and on the right by a slash (/). (It defaults to port 80, the predefined HTTP port; thus, ":80" is redundant.) The fourth part is the actual file path. Most HTTP servers will append a file named index.html or index.htm is the to urls that refer directly to a directory resource. Thus, http://bindprogram.com/ is the same as http://bindprogram.com/index.htm. Java's URL class has several constructors; each can throw a MalformedURLEcxeption. One commonly used form specifies the URL, with a string that is identical to what you see displayed in a browser:


The Next two forms of the constructor allow you to break up the URL into its component parts;



another frequently used constructor allows you to use an existing URL, as a reference context and then create a new URL. from the context. Although this sounds a little contorted,it's really quite easy and useful.



The Following Exampal creates a URL to page on bindprogram.com.



Out Put:
                                    String : http://a143mk.blogspot.in/Help 
                                    Host : a143mk.blogspot.in 
                                    Port : -1 
                                    File : /Help 
                                    Protocol : http
Notice: That the port is -1; this means that a port was not explicitly set.Given URL object, you can retrieve the data associated with it. to access the actual bits or content information of a URL.

No comments :

Post a Comment

Please Write a Message for Programming or something Related issues.