my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how to serialize String[ ][ ] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how to serialize String[ ][ ]" Watch "how to serialize String[ ][ ]" New topic
Author

how to serialize String[ ][ ]

David George
Greenhorn

Joined: Aug 23, 2005
Posts: 10
I wrote a project which need to serialize a String[][] from Server to Client.How should i deal with it?I tried to put all the String[] in an ArrayList.But i can not turn the ArrayList to String[][].What should i do?
Thank you for your help.
Samuel Pessorrusso
Ranch Hand

Joined: Jul 21, 2005
Posts: 164
I would give you some warnings By you question your are probably planing to make all the business logic in your client side but think about when you will use the networked environment... what happens when your client get disconnected from server ?

Client call:
1- lock
2- update
-- get disconnected

that wouldn't be easy to handle with. So I made an OO framework that contains all the business logic (book, unbook and search) and my remote object provides this funcionality.
Thomas Paul Bigbee
Ranch Hand

Joined: Jun 28, 2005
Posts: 71
You could put your String[][] into a Serializable Object and do the below

Note 1.5 Generics used, remove all <xxx> if using 1.4.2, etc...



It worked for me, hope this helps
Tom
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11464
    
  94

Hi Sheng,

Originally posted by sheng peng:
I wrote a project which need to serialize a String[][] from Server to Client.How should i deal with it?I tried to put all the String[] in an ArrayList.But i can not turn the ArrayList to String[][].What should i do?
Thank you for your help.


Why can't you turn the ArrayList into a String[][]? What have you tried? Not knowing what you have done / not done makes it very hard to offer suggestions that you can learn by (rather than just presenting solutions which is not a very good way for you to learn).

But to give you another solution, converting the ArrayList to a String[][]:The for loop which I created to show that it did convert the data for me is a bit faulty, but it is there just to demonstrate the two lines that are the actual conversion, so I am not worried about them.

Regards, Andrew
[ August 23, 2005: Message edited by: Andrew Monkhouse ]

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
David George
Greenhorn

Joined: Aug 23, 2005
Posts: 10
Thank you very much,friends.I think i will pass the SCJD examination with the help of you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to serialize String[ ][ ]