JAVA NETWORKING URL

URL:
 NETWORKING URL
NETWORKING URL

There is variety of URL depending upon the type of resources.
The documents on the internet the uniform or universal resource locator.

URL FORMATS:

The general format-Scheme:address

The scheme specifies the communication protocol.
Various schemes that are used are http, file, news, etc…

https://
File://

URL PATHS:

The path to the web document is similar to the path to the particular file present in the folder.


The URL path that include all the directories along the path to the file is called the complete path.


URL CLASS:

The  Java URL class represents an URL.

This class is pointer to “resource” on the World Wide Web.

url(string urlstring);
url(string protocolname, string hos, int port, string path)
url(string protocolname, string host, string path)

METHOD
DESCRIPTION
getProtocol()
This method returns the name of the protocol which is typically used.generally http is the protocol being used.
getPort()
It returns the port number.
getHost()
This method returns the host name.
Getfile()
This method returns the name of the file which we want to access.











URL CONNECTION
URL Connection is the super class of all classes that represent a communications link between the application and a URL.

Instances of this class can be used both to read from and to write to the resource referenced by the URL.

Method:

public InputStream getInputStream() throws IOException
Returns an input stream that reads from this open connection.
public OutputStream getOutputStream() throws IOException
Returns an output stream that writes to this connection.


Post a Comment

Previous Post Next Post