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
Java

Avatar of undefined
Last Comment
PAQ_Man

8/22/2022 - Mon
CEHJ

ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("array.ser"));
out.write(my2DAray);
out.close();
CEHJ

(That must be enclosed in a try..catch block)
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[][])

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
CEHJ

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

Can you show me how you're doing that?
CEHJ

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

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

myMethod(my2DAray);

?
FearFactor_x

ASKER
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??


⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
CEHJ

ASKER CERTIFIED SOLUTION
PAQ_Man

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.