HttpCookie ToString() Example
Constructs a cookie header string representation of this cookie,
HttpCookieclass ToString() method example. This example shows you how to use ToString() method.This method Constructs a cookie header string representation of this cookie, which is in the format defined by corresponding cookie specification, but without the leading "Cookie:" token.
Here is the code:-
/*
* @Program that Constructs a cookie header string representation of this cookie
* ToString.java
* Author:-RoseIndia Team
* Date:-25-Jun-2008
*/
import java.net.*;
public class ToString {
public static void main(String[] args) throws Exception {
String name = "Roseindia";
String value = "Rohini";
HttpCookie hc = new HttpCookie(name, value);
//Constructs a cookie header string representation of this cookie
String s=hc.toString();
System.out.println("String representation of this cookie is: "+s);
}
} |
Output of the program:-
| String representation of this cookie is: Roseindia="Rohini" |
|