Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Print the URL of a URLConnection

In this section we are going to describe, how to retieve the value of the URL assign to the url object.

Print the URL of a URLConnection

                         

In this section we are going to describe, how to retieve the value of the URL assign to the url object. Here is the complete code of the program in which first of all we establish a connection then display it. In the example we open the connection by using the openConnection() method. After that we use the getURL() which returns the value of this URLConnection's URL field to display the assign URL. 


Here is the Output of the Example :

import java.net.*;
import java.io.IOException;

public class printURLConnection {
  public static void main(String args[]) {

    URL url;
    URLConnection uc;

    try {
      url = new URL("http://roseindia.net/");
      try {
        uc = url.openConnection();
        System.out.println(uc.getURL());
      }
      catch (IOException exp) {
        System.err.println(exp);
      }
    }
    catch (MalformedURLException exp) {
      System.err.println(exp);
    }
  }
}

Here is the Output of the Example :

C:\roseindia>javac printURLConnection.java

C:\roseindia>java printURLConnection
http://roseindia.net/

Download of this example.

 

                         

» View all related tutorials
Related Tags: c com ide print vi using int printer id tar start computer modem activity long where with commercial mode ci

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.