Skip to content

Instantly share code, notes, and snippets.

@codenameone
Created March 2, 2016 11:05
Show Gist options
  • Save codenameone/b94d418ed771c63ffd6f to your computer and use it in GitHub Desktop.
Save codenameone/b94d418ed771c63ffd6f to your computer and use it in GitHub Desktop.
Simplistic example of the Codename One Externalizable interface usage
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();
}
@codenameone
Copy link
Author

Sample code for Externalizable.

From the Codename One project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment