rmi passing parameters

S

smarto59

this my first java rather than rmi program. I faced a little problem
with passing parameters.
I made lookup for the object in client side then defined it. the
program prompts the user
to insert three String data type statements using BufferedReader then
passes them
to the remote method. in server side the first parameter is used to
name a new file using
FileWriter and the second and third arguments to be printed in the
file.
the result: the file is created successfully but the two Strings are
not printed.

this is my a part of my code:

Client:

Code:
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
remoteObject.NewFile(br.readLine(),br.readLine(),br.readLine());
br.close();

server:

Code:
public void NewFile(String name,String str1,String str2)
{
FileWriter fw = new FileWriter(name+".txt");
BufferedWriter bw = new BufferedWriter (fw);
bw.write(str1+" "+str2);
fw.flush();
bw.flush();
fw.close();
bw.close();
}

why don't the two Strings printed :x
 
K

KiLVaiDeN

this my first java rather than rmi program. I faced a little problem
with passing parameters.
I made lookup for the object in client side then defined it. the
program prompts the user
to insert three String data type statements using BufferedReader then
passes them
to the remote method. in server side the first parameter is used to
name a new file using
FileWriter and the second and third arguments to be printed in the
file.
the result: the file is created successfully but the two Strings are
not printed.

this is my a part of my code:

Client:

Code:
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
remoteObject.NewFile(br.readLine(),br.readLine(),br.readLine());
br.close();

server:

Code:
public void NewFile(String name,String str1,String str2)
{
FileWriter fw = new FileWriter(name+".txt");
BufferedWriter bw = new BufferedWriter (fw);
bw.write(str1+" "+str2);
fw.flush();
bw.flush();
fw.close();
bw.close();
}

why don't the two Strings printed :x

Did you handle exceptions correctly in server ?

And have you tried without the flush() ?

K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top