• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Direct Encoding J2ME

 
Isaias C. Barroso
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
How to execute a direct encoding in this class to write it to RMS?
class Test{
int ID;
String name;
int age;
}
Thanks all
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Umm... What is direct encoding?
 
Isaias C. Barroso
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
A manner of serialize this class, utilizing binaries operators.
Best Regards
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so direct encoding isn't some specified way of encoding data but any way of encoding data?
How about constructing an easily parseable string from the member fields and taking a byte[] out of that? E.g. using '\n' as a field delimiter.
 
Liam Quinn
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use DataInputStream and DataOutputStream with a ByteArrayInputStream/ByteArrayOutputStream, readUTF()/writeUTF() for Strings, readInt()/writeInt() for ints.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic