aspose file tools
The moose likes Java in General and the fly likes Byte Array mapping to Java Object Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Byte Array mapping to Java Object" Watch "Byte Array mapping to Java Object" New topic
Author

Byte Array mapping to Java Object

Ahmed Basheer
Ranch Hand

Joined: Apr 15, 2004
Posts: 77
I need to traverse through the bytearray and create an object for it. I have collection of objects/classes with member variables and their set and get methods.The fields in the objects correspond to one or multiple bytes in the byte array.Is there an elegant way to convert this byte array into object? Walking through the byte array seems a basic thought but ugly. Particularily when the byte array changes the code will have to change. The first byte in the bytearray indicates object identifier.
Does Java reflection promises solution here? However I have heard reflection is slow and I might not tend to use it.

Thanks,
Ahmed
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
How is the byte array created? Do you have any other choices, like serialize?

How is the byte array structured? Maybe an example ... what would it look like for an object about you:

From the looks of things right now reflection may be the answer. Don't worry about the speed until you try it and prove it's too slow. I'm told it has gotten better in every JDK release.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Byte Array mapping to Java Object
 
Similar Threads
Inserting image into the oracle database
getting a string embedded in a byte array
Mapping byte stream to Java object
Non-serializable Object to Byte Array
passing byte array to java from javascript