wood burning stoves 2.0*
The moose likes Sockets and Internet Protocols and the fly likes Convert Object to byte array and array size should be 40 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Convert Object to byte array and array size should be 40" Watch "Convert Object to byte array and array size should be 40" New topic
Author

Convert Object to byte array and array size should be 40

Srikanth Nakka
Greenhorn

Joined: Apr 15, 2007
Posts: 26




i want to convert above class to byte array and array size should be 40

please help me on how to convert class to byte array and size should be 40


Thanking You,
Srikanth Nakka
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

You can't without losing data. A long needs 8 data, a char and a short 2. Therefore, you need 8 + 8 + 2*2 + 2 + 2 + 8*2 + 8*2 + 8*2 + 2 = 74 bytes. Even if you use only one byte per char (which is possible for ASCII characters) you still need 48 bytes.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
You might be able to shrink those class members down via huffman encoding, that way you will lose nothing.

Your subject implies to me that you are looking to split up the serialized object into a byte array? If that is the case, I have to ask why? If I am misreading, can you clarify what you are looking to do and why please?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert Object to byte array and array size should be 40
 
Similar Threads
Convert Object to byte array and array size should be 40
Sun Cirtification
Display an array in a swing type box
Short cast to char - bungle
how to convert byte array into short??