I'm using
// This is a defaultHttpClient list & lt; Cookie & gt; Cookies = this.getCookieStore (). GetCookies (); Now, because the cookie does not apply the serial, I can not sort that list.
Edit: (My goal is not only the problem)
My goal is to use DefaultHttpClient with continuous cookies
Anyone with experience Can I take the right path here? Another best practice can be that I have not searched ...
Your own Create SerializableCookie class and copy only the cookie properties during its creation. Something like this:
The public class SerializableCookie implies Serializable {Private string name; Private string path; Private string domain; // ... public serial cookie (cookie cookie) {this.name = cookie.getName (); This.path = cookie.getPath (); This.domain = cookie.getDomain (); // ...} public string getName () {return name; } // ...} Ensure that all properties are also serialized. In addition to primites, for example string class already applies to serializable , so you do not have to worry about it.
Alternatively you can also wrap / decorate the cookie as the transient property (so that it can not be serialized) and WriteObject () and override the code> Read object () Methods are something like this:
Public category SerialCube cookie unrestricted serializable {Personal transient cookie cookie; Public Serial Cookie (cookie cookie) {this.cookie = cookie; } Public Cookie Cook Cookies () {Return Cookie; } Private zero writing object (object overputstream OOS) throws IOException {oos.defaultWriteObject (); Oos.writeObject (cookie.getName ()); Oos.writeObject (cookie.getPath ()); Oos.writeObject (cookie.getDomain ()); // ...} The Private Zero Read Object throws classlessfound expressions (ObjectInstस्ट OIS), IOException {ois.defaultReadObject (); Cookie = new cookie (); Cookie.setName ((string) ois.readObject ()); Cookie.setPath ((string) ois.readObject ()); Cookie.setDomain ((string) ois.readObject ()); <... Finally use that class in
Comments
Post a Comment