Link to home
Start Free TrialLog in
Avatar of FearFactor_x
FearFactor_x

asked on

Serializing a 2D String Array

hi all,
        how do we Serialize an String[][] .. in my code..
i have to serialize a 2-D string array called parameters. I dot it like this..

    String my2DAray[][]= new String[][]{
                                          {"param1","N",""},
                                          {"param2","D","out"},
                                          {"param3","S","out"},
                                        };
   

Serializeable[] params = new Serializable[] {my2DAray});

The problem arises when i try to inovke a remote method called myMethod using these as the parameters . The probelm that i get is..

"No such Method myMethod(java.lang.String)"

The signature of myMethod is
public void myMethod(String[][] args )

Pls help me to resolve this issue

Novice
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("array.ser"));
out.write(my2DAray);
out.close();
(That must be enclosed in a try..catch block)
Avatar of FearFactor_x
FearFactor_x

ASKER

THe Error that i get is not a compile time one. the source compiles but when i try to invoke the REMOTE method that has to accept a String array it doesnt construct the serialized string array back rather it searches for a match
myMethod(String) rather than looking for myMethod(String[][])

>>but when i try to invoke the REMOTE  ...

Can you show me how you're doing that?
>>
The signature of myMethod is
public void myMethod(String[][] args )
>>

If that's the case, why can't you simply do

myMethod(my2DAray);

?
hi all , i got the solution to the problem.


I had to pass the classTypes while making the Remote call.. as follows..

 Class[] paramTypes={String.class,Boolean.class,String[][].class};


Thanx everyone for ur comments. How do i get back my points??


ASKER CERTIFIED SOLUTION
Avatar of PAQ_Man
PAQ_Man
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial