Created
March 2, 2016 11:05
-
-
Save codenameone/b94d418ed771c63ffd6f to your computer and use it in GitHub Desktop.
Simplistic example of the Codename One Externalizable interface usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void externalize(DataOutputStream out) throws IOException { | |
out.writeUTF(name); | |
if(value != null) { | |
out.writeBoolean(true); | |
out.writeUTF(value); | |
} else { | |
out.writeBoolean(false); | |
} | |
if(domain != null) { | |
out.writeBoolean(true); | |
out.writeUTF(domain); | |
} else { | |
out.writeBoolean(false); | |
} | |
out.writeLong(expires); | |
} | |
public void internalize(int version, DataInputStream in) throws IOException { | |
name = in.readUTF(); | |
if(in.readBoolean()) { | |
value = in.readUTF(); | |
} | |
if(in.readBoolean()) { | |
domain = in.readUTF(); | |
} | |
expires = in.readLong(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample code for Externalizable.
From the Codename One project