URI ToString() Example
Returns the content of this URI as a string.
URIclass ToString() method example. This example shows you how to use ToString() method.This method Returns the content of this URI as a string.
Here is the code:-
/**
* @Program that Returns the content of this URI as a string.
* ToString.java
* Author:-RoseIndia Team
* Date:-24-jun-2008
*/
import java.net.*;
public class ToString {
public static void main(String[] args) throws Exception {
String scheme = "http";
String userInfo = "girish";
String host = "tewari.com";
int port = 8080;
String path = "/mail/";
String query = "open";
String fragment = "inbox";
URI uri = new URI(scheme, userInfo, host, port, path, query, fragment);
System.out.println("Given new URI is: " + uri);
//Returns the content of this URI as a string.
System.out.println("Given URI as a string is: " + uri.toString());
}
} |
Output of the program:-
Given new URI is: http://girish@tewari.com:8080/mail/?open#inbox
Given URI as a string is: http://girish@tewari.com:8080/mail/?open#inbox |
|