File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Joe Wilkes
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Reflection to make an array of the variable states and then serialize only that.
When you retrieve populate only that.
 
Joe Wilkes
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Joe Wilkes
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 194
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh Yes! I am sorry, next time i will not do that
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic