aspose file tools*
The moose likes I/O and Streams and the fly likes Serializable ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Serializable ArrayList" Watch "Serializable ArrayList" New topic
Author

Serializable ArrayList

david foley
Ranch Hand

Joined: Dec 01, 2012
Posts: 75

I am trying to Read my Serialize data back into the Program.
but when i click on load the console is giving me back this

Person@3b7418ba
Person@430379d4

Is their Any Way of getting it into a String.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2854
    
  11

Yes, although it's not related to serialization. You just need to override the toString() method in your Person class to build up a String representation in any format you want.
david foley
Ranch Hand

Joined: Dec 01, 2012
Posts: 75
Thanks,

I'll will give this go,

Should a create another method

Public String tostring()
{
Return Id + "" + firstname + "" + last name;
}
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

David

To ensure you override the toString method properly, use this:
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2317
    
  49
James Boswell wrote:To ensure you override the equals method properly, use this:

I think you mean "To ensure you override the toString method properly..."
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

Thanks Tony, I've posted something similar on another thread and got my method names mixed up!
david foley
Ranch Hand

Joined: Dec 01, 2012
Posts: 75

Thanks Lads that worked well.


You couldn't point me to a direction,

on How you can get the File to Read into Text Fields. i have a number of Text Fields
for First Name etc..

and Use a Next Button to display the Next Serialize data on File ("For the Next Button i would have to use maybe a Loop")
since i am using ArrayList i wouldn't have to check if its at the end of file as ArrayList should do this automatically
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Serializable ArrayList