实现CookieStore,Runnable
import java.net.*; import java.util.*;/** 来 自 N o w J a v a . c o m - 时代Java**/ public class PersistentCookieStore implements CookieStore, Runnable { CookieStore store; public PersistentCookieStore() { // get the default in memory cookie store store = new CookieManager().getCookieStore(); // todo: read in cookies from persistant storage // and add them store // add a shutdown hook to write out the in memory cookies Runtime.getRuntime().addShutdownHook(new Thread(this)); } /*来 自 nowjava - 时 代 Java*/ public void run() { // todo: write cookies in store to persistent storage } public void add(URI uri, HttpCookie cookie) { store.add(uri, cookie); } public List<HttpCookie> get(URI uri) { return store.get(uri); } public List<HttpCookie> getCookies() { return store.getCookies(); } public List<URI> getURIs() { return store.getURIs(); } public boolean remove(URI uri, HttpCookie cookie) { return store.remove(uri, cookie); } public boolean removeAll() { return store.removeAll(); } }