CookieManager(): This method is available in the java.net.CookieManager class of Java.
Syntax:
java.net.CookieManager.CookieManager()
Create a new cookie manager.
This constructor will create a new cookie manager with a default cookie store and accept the policy.
Parameters: NA
Exceptions: NA
Approach
Java
package com.CookieManager;import java.net.CookieManager;public class CookieManager1 {public static void main(String[] args) {CookieManager cookieManager = new CookieManager();System.out.println(cookieManager);}}
Output:
java.net.CookieManager@2d363fb3
Some other methods of CookieManager
CookieManager(): Create a new cookie manager.
CookieManager(CookieStore, CookiePolicy): This method creates a new cookie manager with a specified cookie store and cookie policy.
get(URI, Map): This method gets all the applicable cookies from a cookie cache for the specified uri in the request header.
getCookieStore(): To retrieve current cookie store.
put(URI, Map): This method sets all the applicable cookies, examples are response header fields that are named Set-Cookie2, present in the response headers into a cookie cache.
setCookiePolicy(CookiePolicy): To set the cookie policy of this cookie manager.
No comments:
Post a Comment