Simple Encoding/Decoding in Java