Solved

Streams ad RMI parameters

Posted on 1998-11-12
5
165 Views
Last Modified: 2010-03-30
Hi,

I would like to pass a stream as a parameter of a remote method, but I have no success doing so.

If anyone know how it may be achived I will be most thanksfull.

Thanks,
Guy Loewy.
0
Comment
Question by:optimal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:msmolyak
ID: 1227339
Not a stream object I hope. Imagine you create a file input stream object which has the name of a local file and logic on how to read it. If you manage to pass that object to the remote machine, what good will it do there?

The alternatives are:

1. Reading the entire stream in serializable data structure (String for example) and pass it as a parameter.
2. If the stream contains too much data, you can use Sockets to communicate between the client and the server side.

If you describe you situation I might be able to think of something better.

Michael
0
 

Author Comment

by:optimal
ID: 1227340
Hi msmolyak,

I already tried to read the stream into a string, but it seems that either using FileInputStream (which means using byte[]) or FileReader (which means using char[]) and storing the data in a String object cause my application to loose data (I transfer binary files). Some of the bytes are being altered (according to the data from the String contents.I found it strange, but maybe that's because String converts bytes into chars or visa versa. Anyway, the String on the remote Server is altered and the binary file is not the same.
I might use sockets, but I'm sure it should be posibble to transfer whole binary files in one chunk.
0
 
LVL 5

Expert Comment

by:msmolyak
ID: 1227341
If the file is binary I would not use Readers and Strings. Stick with byte arrays. Did you try to encapsulate a binary array into some serializable object, Vector, for example and then pass that object as a parameter. First use ByteArrayOutputStream to write the data you read from your stream, then convert it to byte array, this way you would not have to concatenate pieces manually.
0
 

Author Comment

by:optimal
ID: 1227342
Thanks msmolyak,

I used a Vector object to move the byte arrays and it works great,

Guy.

Pealse send as an answer.
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 200 total points
ID: 1227343
I am glad it worked.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question