Solved

Streams ad RMI parameters

Posted on 1998-11-12
5
163 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
  • 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web services creation SOAP vs REST 5 42
windows explorer path to command prompt 5 46
Why my table column Id is not passed to java object? 4 39
Java string replace 11 48
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

831 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