Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Released under the MIT License https://raw.github.com/mit-cml/app-inventor/master/mitlicense.txt

import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.CookieStore;

public class Main {
    /**
     * Clears the cookies in the given cookie handler. Cookies can only be cleared if the
     * cookieHandler is a CookieManager with a non-null CookieStore.
     *
     * @param cookieHandler the cookie handler where cookies should be cleared
     * @return true if cookies were cleared; false otherwise
     */
    public static boolean clearCookies(CookieHandler cookieHandler) {
        if (cookieHandler instanceof CookieManager) {
            CookieManager cookieManager = (CookieManager) cookieHandler;
            CookieStore cookieStore = cookieManager.getCookieStore();
            if (cookieStore != null) {
                cookieStore.removeAll();
                return true;
            }
        }
        return false;
    }
}