The URL Class



The URL class enables you to get resource from remote system. After creating a URL object you can retrieve information stored in URL in one of three ways.

Use the getCotenet() method in the URL class to fetch the URL’s content directly

Use openConnection method to get URLConnection to the URL

Use openStream() method to get an InputStream to the URL

The full URL string is the form you are probably most familiar with

URL homepage=new URL(“http://www.xyz.com”);

You can create URL by giving the protocol, hostname, filename, and an optional port number

URL homepage=new URL(“http”,”www.xyz.com”,80);

Random Posts

  • Basic Java Interview Question
  • Thread safety of the servlet
  • STRUTS Interview Questions
  • Difference between getCurrentSession() and openSession()
  • What are the elements of JSP

Post a Comment