aspose file tools*
The moose likes Java in General and the fly likes How do I turn this object into an array.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I turn this object into an array...." Watch "How do I turn this object into an array...." New topic
Author

How do I turn this object into an array....

Joe Wilkes
Greenhorn

Joined: Oct 29, 2005
Posts: 7
is there a way without giving me the code, just giving me an explanation of how to put this data into an array that I can then serialize the array instead of just the member data. Is this clear?

Thanks,
Joe


[ March 09, 2006: Message edited by: Joe Wilkes ]
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Use Reflection to make an array of the variable states and then serialize only that.
When you retrieve populate only that.


-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
Joe Wilkes
Greenhorn

Joined: Oct 29, 2005
Posts: 7
I am not sure what that even means... Can you explain a little more. This is for my advanced java class and we are just getting into I/O.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

That looks like working code. Why do you need to put something (I couldn't understand what) into an array? Does your assignment say to put something into an array, or is that your idea of a workaround for some problem you are having?
Joe Wilkes
Greenhorn

Joined: Oct 29, 2005
Posts: 7
This is what the program is supposed to do. He wants there to be user input so I though this would be the easy way, maybe I am wrong. Would an array of strings work better to store data to?


Create a program that stores an array of objects (your choice) and then uses serialization to store that array of objects to a file. The objects in the array must contain at least one reference to another object. You will have to do a "deep copy" which means that all objects referenced must be "serializable"
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Oh i think the question is quite straightforward.
Make a Array of the Family Members class and populate each element of that array with some entries.
Now that you have the Array of Family members (each refering to another set of objects, name, address, phone etc.) you have to only serialize this array (Array is also an Object).
Write this serialized object to a file.
If you need further help feel free to contact me.
Hope that helps!!
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Hi Joe,
I have modified your code a little. I could not test the code as i do not have a jdk1.5
Please see the comments on the code. Modify the Method that reads the FAmily Members and the code should work fine.
Hope that helps. Do reply in case you find issues or anyways

Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
is there a way without giving me the code, just giving me an explanation of how to put this data into an array that I can then serialize the array instead of just the member data.
Doing someones homework for them doesn't really help them at all.
[ March 11, 2006: Message edited by: Garrett Rowe ]

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Joe Wilkes
Greenhorn

Joined: Oct 29, 2005
Posts: 7
Thats ok, I figured it just before I read the post. Thanks for all the info guys, you really got me back on the right track....
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Oh Yes! I am sorry, next time i will not do that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I turn this object into an array....